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.
adduser user-name
Example:
adduser surendra
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.
passwd username
Example:
passwd surendra
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
Output:
surendra:x:1000:1000:surendra,,,:/home/surendra:/bin/bash
or use id command to see more details.
id surendra
Output:
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)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - 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