Learn GNU/Linux Commands (10): User - passwd, useradd, usermod, userdel

GNU/Linux allows multiple accounts, or users. When the system is installed, at least one user, the superuser, or root is made. And perhaps a normal user is made as well. If the home directory of the normal user is also made, the normal user can manipulate files, install programs under its home directory. But the normal user can not manipulate other files on the system, including system files and those made by other users.

The superuser, or root has administration privileges. Root can access all files on the system and add, change, or delete any other users.

The information of all users in a GNU/Linux system is normally stored in the file "/etc/passwd".


The passwords of all users are encrypted and normally stored in "/etc/shadow".

Normal users can set their own password but often with restrictions.

Root can manipulate all users' passwords.

Set Password

passwd [USER]

Follow the instructions to set the password. If USERNAME is omitted, set the password of the current user. For example:

[Texpion@com ~]$ passwd
Changing password for user Texpion.
Current password:
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

Other Manipulations (by root only)

"passwd" options:

  • -d, --delete: delete the password for the named account so that the account can be logged in without a password.
  • -l, --lock: make the named account unable to be logged in with even the correct password. Note that the user can still log in by other means of authentication such as the ssh public key authentication.
  • -u, --unlock
  • -f, --force: Force the specified operation.

Make a New User

useradd -m USER

Make (create) a new user. By default, the new user will belong to a newly made group named USER (same as the user name).

"useradd" options:

  • -m, --create-home: create the user's home directory, which is "/home/USERNAME" by default.
  • -d, --home-dir HOME_DIR: Set the home directory of the new account as HOME_DIR. Should be used with "-m".
  • -g, --gid GROUP: set the primary group of the new account, GROUP is a group name or a group id (gid).

Change a User's Name

usermod -l NEW_NAME OLD_NAME

Change a User's name (login name).

"usermod" option:

  • -l, --login NEW_NAME: new value of the login name.

Change a user's Home Directory

usermod -d HOME_DIR USER

Change a user's home directory. To move contents of the old home directory to the new location, add "-m".

"usermod" option:

  • -d, --home-dir HOME_DIR: new home directory for the user account.
  • -m, --move-home: move contents of the home directory to the new location (use only with -d).

For example, the following command moves contents of the home directory of the user Texpion to the new home directory "/home/new".

[root@com ~]$ usermod -md /home/new Texpion

Change a User's Group(s)

Change a User's Primary Group

usermod -g GROUP USER

Change a user's primary group. GROUP can be a group name or a group id (gid).

"usermod" option:

  • -g, --gid GROUP: force use GROUP as the new primary group.

Append supplementary groups

usermod -aG GROUP... USER

Append GROUP(S) as USER's supplementary group(s). GROUP can be a group name or a group id (gid).

"usermod" option:

  • -G, --groups GROUPS: new list of supplementary GROUPS.
  • -a, --append: append the user to the supplemental GROUPS mentioned by the -G option without removing the user from other groups.

We also introduce adding a user to a group with the "gpasswd" command in the Previous Part.

Delete a User

userdel USER

"userdel" options:

  • -r, --remove: remove home directory and mail spool
  • -f, --force: force some actions that would fail otherwise, e.g. removal of user still logged in or files, even if not owned by the user. Note that this option is dangerous and may leave your system in an inconsistent state.




Intel 7th and 8th generation processor graphics driver for Windows 7/8/8.1

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part II - Fidelity

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part I - Lossless

OBS Studio settings for best quality (loseless) recording

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part III - Quality

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part IV - Decode

Install VMAF on Fedora, CentOS/Red Hat (RHEL)