How to Create Users in Linux (useradd Command)

In this course of Linux commands, we will introduce How to Create Users in Linux (useradd Command). We start tutorial by mentioning the structure and example. In Linux, the adduser command is for creating a user. There are several commands and methods to create a user in Linux, such as useradd, adduser. One of the features of the Linux operating system is multi-user support.
It is possible to create different users and separate groups by specifying the access level for each user or group in Linux. The two commands adduser and useradd work similarly and both commands have the same behavior.
NAME:

adduser – add a user to the system

SYNOPSIS:

adduser [options] [–home DIR] [–shell SHELL] [–no-create-home] [–uid ID] [–firstuid ID] [–lastuid ID] [–ingroup GROUP | –gid ID] [–disabled-password] [–disabled-login] [–gecos GECOS] [–add_extra_groups] user

adduser –system [options] [–home DIR] [–shell SHELL] [–no-create-home] [–uid ID] [–group | –ingroup GROUP | –gid ID][–disabled-password] [–disabled-login] [–gecos GECOS] user

when we try to create user, we have these questions:

  • Username: The username or login name should be between 1 to 32 characters.
  • Password: password save in /etc/shadow file in an encrypted format
  • User ID (UID): The user id is 1004. (“0” is for root user)
  • Group ID (GID): The group id is “1004” and save in directory “/etc/group”
  • User Info: information like Full name, Room Number, Work Phone, Home phone, Other
  • Home Directory: path is “/home/username”
  • Shell: user is “/bin/bash”

 

The Sudo utility allows users to run programs while using the security privileges of another user, usually root (superuser). The function of Sudo is like “run as” in Windows system.
Steps to set up and run Sudo (to run all commands as administrator). If the system is not already configured and enabled to use Sudo, changes must be made so that a non-root user can manage the system.

• In the command line, enter the command :

> su

You will be prompted for the root password.

 

Create username:

> adduser <user_name> sudo

> Sudo adduser user1

 

 

You can find other learning for Linux by clicking here.

Share :
1,486
keyboard_arrow_up