It is used to create a new user and update default new user information.

Syntax : 

useradd [options] LOGIN

Useradd – D

Useradd -D [options]

Without specifying -D option, useradd command is  used the values specified on the command line and the default values from the system  creates a new user account

Some of the options as follows:

-c, –comment : It can be any text string. It is currently used as the field for the user’s full name and generally a short description of the login.

-d,–home : The new user will be created using HOME_DIR as the value

-e, –expiredate EXPIRE_DATE

-f, –inactive INACTIVE : The number of days after a password expires until the account is disabled permanently.

-h, –help: Display a help message, and exit

-r, –system : Create a system account

-m, –Do not create the home directory

-s, User’s login shell, /bin/bash as default

Some of the examples as follows

How to add a user through useradd command

To add user account, use this command $ sudo useradd  newuser

How to create a group with same name as the user

Using -U option, use $ sudo useradd -U user

How to change default login shell

$ useradd -D| grep -i shell

How to assign a shell to user manually

$ useradd -s /bin/sh user

How to create user without home directory

$ su – testuser










Categorized in:

Tagged in:

, ,