Social profiles

Create user

The id command prints information for a certain user. Use it like this:

# id username

To create a new user:
# useradd --home /home/username username
# passwd username

If you want to activate the user you have to assign a password, because initially the user account is in disabled state.

These are some useful useradd options to create user:

-c : sets a comment for the user.
-s : is used in order to define the user’s default login shell. If not used, then the system’s default shell becomes the user’s default login shell.
-r : creates a user with UID<500 (system account)
-d : sets the user’s home directory. If not used, the default home directory is created (/home/username/)
-M : the home directory is not created. This is useful when the directory already exists.

The newly created user don’t have the ability to login to a shell, To enable the shell login you have to issue the following command:

# useradd -c "This user cannot login to a shell" -s /sbin/nologin username
# passwd username

Change the user’s password

To change a user’s password:

# passwd username

If you want to change the current user’s password type without specifying a username.

Check more Linux related stuff from Linux Category.

One thought on “Create user in Linux”

  1. I simply want to say I’m very new to weblog and absolutely loved your blog site. Likely I’m want to bookmark your site . You certainly have exceptional posts. Appreciate it for sharing your website page.

Leave a Reply

Your email address will not be published. Required fields are marked *