This is a small “how-to” on adding users in Linux. As Linux is multi-user supporting operating system, we can add multiple users. Linux administrators/superuser can create new user accounts in Linux. This can be accomplished by executing adduser command from terminal. This command will create user accounts with normal privilegs and default settings. The default settings such as home directories, type of the shell, UID and GID as well are taken from /etc/default/useradd file. Only root user can execute this command. If a normal user want to create accounts in the system he should be granted sudo access for useradd command.
Step 1: Add user account with following command. This will create a user in the machine and edit /etc/passowd file with details.
Note 1: There is one more command useradd which will work similar to adduser command. When an user is created the files such as /etc/passwd, /etc/group are edited with new user details.
Note 2: When an user is created the /etc/skel, /etc/useradd/defaults files are used to crate common user properties.
Step 2: Set password for this user so that he can login to the machine. If this step is missed user can not login to this machine.
Note 3: Once we create password, a password hash and user details are created in /etc/shadow file.
Step 3: Check if the user account is created successfully or not using below grep or id command.
grep surendra /etc/passwd
or use id command to see more details.
uid=1000(surendra) gid=1000(surendra) groups=1000(surendra),126(admin),1001(libvirtd)
This command should show you a line contain about user: surendra details. From the above output, we can say user and group ID is assigned with 1000, and this user surendra is member of admin, libvirtd groups as well.
Latest posts by Surendra Anne (see all)
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018
- wget download a file to a directory in Linux/Unix - June 4, 2018
- GIT: How to compare two GIT branches? - June 3, 2018