0% found this document useful (0 votes)
9 views14 pages

Lesson 6 User Management Essentials

This document covers user management essentials in Linux, focusing on commands such as useradd, userdel, usermod, groupadd, and groupdel. It provides syntax and examples for adding, modifying, and deleting user and group accounts, as well as managing user passwords. Additionally, it explains where user account information is stored in the system.

Uploaded by

rejilib748
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views14 pages

Lesson 6 User Management Essentials

This document covers user management essentials in Linux, focusing on commands such as useradd, userdel, usermod, groupadd, and groupdel. It provides syntax and examples for adding, modifying, and deleting user and group accounts, as well as managing user passwords. Additionally, it explains where user account information is stored in the system.

Uploaded by

rejilib748
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Linux Fundamentals

Lesson 7 User Management


Essentials
Lesson Objectives

In this lesson, you will learn:


▪ Administrator commands like
• Useradd
• Userdel
• Usermod
• Groupadd
• Groupdel etc.
Commands for User Management

Command Description
useradd Adds a new user account.
userdel Deletes an user account.
usermod Modifies an user account.
groupadd Adds a new group.
groupmod Modifies an existing group
(for example, changes the
GID or name).
groupdel Deletes a group
useradd Command

The useradd command adds new user to the system. Command also
includes various parameters related to the user.
Syntax:
▪ $useradd [-c comment] [-d dir] [-e expire] [-g group] \ [ -G group [ ,
group...]] [ -m ] [-u uid ] \ [-s shell] <loginname>
The login parameter must be a unique string.
Username cannot comprise ALL or default keywords.
▪ Example: $useradd myuser
▪ Example: $useradd -u 3000 -g other -d /home/bcalkins -m -s /bin/sh \ -
c "Bill Calkins, ext. 2345" bcalkins
useradd Command Options

Option Description

-u <uid> Sets the unique UID for the user.

-g <gid> Specifies a predefined GID or name for the user that will be the user's primary group.

-G <gid> Defines the new user's secondary group memberships. You can enter multiple groups, but they must be
separated by commas.

-m Creates a new home directory if one does not already exist

-s <shell> Defines the full pathname for the shell program to be used as the user's login shell. The default is /bin/bash if
a shell is not specified.

-c <comment> Specifies the user's full name, location, and phone number, in a comment.

-d <dir> Specifies the home directory of the new user

-e <expiration> Sets an expiration date on the user account. Specifies the date on which the user can no longer log in and
access the account. After the specified date, the account is locked. Use the following format to specify the
date: mm/dd/yy.

<login-name> Specifies the user login name to be assigned to this account.


Changing the Password

Passwd command is used to change password of an user. User can change


his/her password if required.
▪ Ex: $passwd
Only the root user can change the password of other users. To change the
password as root following command is used,
▪ Ex: $passwd <username> # To Change the password of user from root
Administrator can also delete the password using,
▪ $passwd –d <username>
Modifying User Accounts

usermod command is used to modify some of the parameters set with


useradd.
Syntax:
▪ $usermod [ -u uid ] [-g group] [ -G group [ , group...]] [ -d dir [-m]] [-s
shell] [-c comment] [-l new_name] [-e expire] <loginname>
Ex: $usermod –s /bin/bash oracle
▪ Sets bash as login shell for the user oracle.
Deleting User Accounts from Command Line

userdel command is used to remove users from the system.


Ex: $userdel [-r] <login-name>
▪ -r removes the user's home directory from the local file system.
Example: $userdel bcalkins
▪ $userdel -r usera
Adding Group Accounts

groupadd command is used to create a new group in the system.


Syntax:
▪ $groupadd <group-name>
Ex:
▪ $groupadd dba
▪ $groupadd -g 301 class1
Modifying Group Accounts

groupmod command modifies the group details and makes appropriate


changes in the database.
Syntax:
▪ groupmod [-n <name>] <group-name>
Ex:
▪ groupmod -g 400 class1
Deleting Group Accounts

groupdel command is used by the administrator t o remove/delete a


group.
User must be removed before removing his/her primary group.
Filesystem to be checked maually to ensure that no files are remaining
owned by the deleted group. Groupdel will not do this for you.
Syntax:
▪ $groupdel <group-name>
Ex:
▪ $groupdel dba
User Information

All user account information except encrypted password is stored in


/etc/passwd.

The fields in /etc/passwd are as follows:


▪ username:password:UID:GID:comment:home_directory:login_shell.

The /etc/shadow file contains the users' encrypted passwords and is


very important to protect.
Summary

In this lesson you have learnt


▪ Administrator commands like
• Useradd
• Userdel
• Usermod
• Groupadd
• Groupdel etc.
Review Questions

Question 1:List various administrator commands used to manage


users and groups.

Question 2: ____ command is used to modify groups.

You might also like