Create User Account
A user is an entity, in a Linux operating system, that can manipulate files and perform several other operations. Each user is assigned an ID that is unique for each user in the OS. Linux is multiuser OS where multiuser features enable many people to have accounts on a single Linux system with their data kept secure from others. Multitasking enables many people to run many programs on the computer at the same time, with each person able to run more than one program. Sophisticated networking protocols and applications make it possible for a Linux system to extend its capabilities to network users and computers around the world. The person assigned to manage all of a Linux system’s resources is called the system administrator.
After installation of the operating system, the ID 0 is assigned to the root user and the IDs 1 to 999 (both inclusive) are assigned to the system users and hence the ids for local user begins from 1000 onwards.
In a single directory, we can create 60,000 users.
During the time of installation Linux system, it allow creation of additional user account. Root account is always created in all Linux Destro while in some it might be deactivated. As root users can make any changes so we should avoid using root account for day to day task.
There are two ways to create new user account: GUI or CLI.
Here we will follow CLI method of Creating user:
- Below is the command to add User account called ghimire, in Linux
# useradd -c “R Ghimire” –d /mnt/home/ghimire/ -s /bin/csh –e 2021-12-15 ghimire - Here useradd is the command to add user account
- -c option is for comment: here “R Ghimire” is a description of user ghimire
- -d: means home directory; if you did not specify this user home directory will be created inside /home directory and /home/rghimire
- -s: shell
- -e: expiry date of the user account
- Finally we specify username : ghimire
- OR simply we can use below command to create user account.
- # useradd ghimire
- To set password of user ghimire
# passwd ghimire
Changing password for user ghimire.
New password: **********
Retype new password: **********
To verify the user is created open file /etc/passwd
[raju@localhost ~]$ cat /etc/passwd
on the last line you will see
ghimire:x:1003:1003::/home/ghimire:/bin/bash
- Here: ghimire: username
- x: used to Hash of password but now it has been moved to shadow file
- 1003: user id and 1003: group id (group name of ghimire is ghimire)
- /home/ghimire: user home directory
- /bin/bash: user default shell.
To add user to specific Group
To create Group follow this page:
To add user to specific group use
´# usermod -Ga sales,marketing ghimire
above command will add ghimire use to sales and marketing group.
To change or reset the user password use following command
[root@localhost ~]# passwd ghimire
Changing password for user ghimire.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
if the password does not meet the complexity it will tell you BAD PASSWORD.
To delete user account
Just as usermod is used to modify user settings and useradd is used to create users, userdel is used to remove users. The following command removes the user chris:
# userdel -r ghimire
Here, the user ghimire is removed from the /etc/password file. The –r option removes the user’s home directory as well. If you choose not to use –r, as follows, the home directory for ghimire is not removed:
# userdel ghimire
Keep in mind that simply removing the user account does not change anything about the files that user leaves around the system (except those that are deleted when you use -r).
However, ownership of files left behind appear as belonging to the previous owner’s user ID number when you run ls -l on the files.
Before you delete the user, you may want to run a find command to find all files that would be left behind by the user. After you delete the user, you could search on user ID to find files left behind. Here are two find commands to do those things:
# find / -user ghimire -ls