Users are someone those who have given permission to access the server and enjoy the resources of the server. They can connect to the server via ssh and they can create, modify and delete the files and directories. Users can run the application provided that they has permission to do that. To manage the users in easy manner, we generally put them into groups.
For example, 25 students are from std 9 and just say ‘vinay’ is one among them. To assemble all the student from std 9. we will not call one by one student to assemble, simply we use std 9 students are requested to assemble. Here vinay is the user and std 9 is group name.
This post will explain various way of creating and managing the users and groups.
1. To List the users :
user-name:x:user id:group id:Comment Section:home directory:default shell
group-name: password : group id: users list
useradd malik -c nxt -m -d /home/malik
|create users home directory
|Setting the home director
Home Directory : It’s a directory. Whenever user is logging they will go to respective home directory always. In that directory users have their .bashrc scripts and some hidden directories. We will discuss what these scripts is doing in near future.
Note : when we are using -m option. Home directory should not exists. so that -m option will create and then -d option will assign to the user. Suppose we are using -m option and still we are using home directory which already exist. we will get the following error.
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
But still user will be created.
useradd sam -m -d /home/sam -u 1003 -g 1000
For every users we can make primary group(denoted by: -g) and secondary group(denoted by: -G).
4. Modify the user
Now we are going to set the password for malik.
usermod malik -p malik -e 2012-11-27
|Expiry date for the user
5. Delete the user
The below will not delete the home directory of malik. So all his content will be there in his home directory (/home/malik). Ultimately this will affect the /etc/passwd file.
Suppose we want to delete the user including the home directory. we can use the below option.
userdel -r malik
Another simple way of adding the user is by the command ‘adduser’. This will create the user while prompting the home directory, password and so on. We can fill mandatory things and we can ignore the rest.