Users
Add a user
1. Open terminal and login as root user mode
#sudo Su
then type your password
2. To add new user use the useradd command and to set the password for that user use passwd command as shown below.
#useradd name_of_the_user
#passwd username
Whenever you add/ remove/modify a user, three configuration files should be modified in the /etcdirectory.
1. /etc/passwd
2. /etc/groups
3. /etc/shadow
The password configuration file modification
A new user properties containing username,password,userid,groupid,home directory fields are added when an user is created in the configuration file.
user1:x:1001:1001::/home/user1:/bin/sh
The representation of the six fields are
Field 1 = username = user1
Field 2 = password = xxxx ( encrypted text )
Field 3 = userid =1001
Field 4 = group id = 1001
Field 5 = home directory = /home/user1
Field 6 = Shell = /bin/sh
The user id 0-499 is allocated for the system user and the new user starts from the user id 500 (for Redhat and Fedora).
The user id 0 -1000 is allocated for the system user and the new user starts from the user id 1001 (for Ubuntu )
The Shadow Configuration file modification
The shadow configuration file contains username and encrypted password. The Shadow configuration file is present in the /etc/shadow directory.
The group configuration file modification
The group configuration file contains user name, encrypted password and user id. Whenever a user is created group name is automatically created with the username. Group id are stored in /etc/groupdirectory.
Groups
Add a group
Users are assigned to a group. Each group is assigned a unique Group id number. Group id are stored in the /etc/group. All users in a group can share files that belong to the group.
To add a new group
#groupadd name_of_the_group
If you want to add a user to a particular group at the time of user creation
#useradd –g groupname username
The group configuration file is modified as show in the figure
The shadow configuration file is modified as show in the figure
Delete a user
To delete a user userdel command is used.
#userdel username
The information associated with the user is also deleted in the configuration files.
Remove a group
To delete a group groupdel command is used.
#groupdel groupname
The information associated with the group is also deleted in the configuration files.