Managing users and groups
Learn how to manage users and groups
I. Users :
Most common $COMMANDS and FILES used to manage users. consult "man $command " for more informations.
Commands :
useradd <username> -> to add new user.
userdel <username> -> to delete an existed user.
usermod -option <username> -> to modify a user characteristics.
Files :
vim /etc/default/useradd -> useradd default config file.
vim /etc/passwd | vipw -> verify the creation of your user with wanted properties.
vim /etc/shadow -> stores encrypted user passwords and is accessible only to the root user.
II . Groups :
Most common $COMMANDS and FILES used to manage groups. consult "man $command " for more informations.
Commands :
groupadd <groupname> -> to create new group.
groupdel <groupname> -> to delete an existing group.
groupmod <groupname> -> modify a group definition on the system.
lid -g <groupname> -> display the members of <groupname>.
groupmems -g <groupname> -l -> administer members of a user's primary group
other commands : groups | id | getent group ..
Files :
vim /etc/group | vigr -> to list groups in your system.
vim /etc/gshadow -> readable only by the root user and contains an encrypted password for each grou
Configuration files :
Let's start explaining the contents of /etc/passwd "vipw" file.
here we took an example of a user called chxmxii. as you can see this line contains 7 fields separated by ":", I will try to explain it for you one by one.
chxmxii : is the username.
x : is the password.
1000 : User ID.
1000 : Group ID.
RHEL8VM : Comment. "GECOS"
/home/chxmxii : Home Directory
/bin/bash : shell.
After understanding /etc/passwd, lets move on and find out what does /etc/shadow contains.
Continuing with the same user chxmxii, unlike "vipw" /etc/shadow contains 9 fields which are :
chxmxii : username
$1$KfyGjDYU$OPkmq6g6pFehQk0DxUiZ80 : encrypted password using the format $type$salt$hashed and eight to 12 characters long.
18988 : last password change since 1st January 1970.
0 : The minimum number of days that must elapse before the password can be changed by the user.
99999 : The number of days after which the password must be changed.
7 : Warning period.
? : Inactivity period ( since Jan. 1, 1970).
? : Expiration date (The date on which the account was disabled.).
? : This field is left empty and reserved for future use.
Hints :
If you want to edit the password quality go to "/etc/security/pwquality.conf" .
If you want to edit the user configuration go to "/etc/default/useradd" .
If you want to edit the umask and pw.age.. go to "/etc/login.defs" .
make sure to create a backup file before editing directly.
f.g : cp /etc/login.defs /etc/login.defs-original
Created files under /etc/skel will be created in /home/$USER upon creation.
I . Practice Time:
Create user chxmxii with the properties below :
UID : 1544 | GID : 1552 | GECOS : RHELV8 | HomeDir : /home/chxmxii | Shell : /bin/zsh
make sure chxmxii is a member of wheel group.
Make sure a file with name "Rules" is created in user home directory upon creation.
Answer :
You have just finished learning users and group managing, lets pass to the next module ownerships and permissions.
Last updated
Was this helpful?