navigation

How to Manage Users in Linux

Method 1 of 4:

Adding Users

  1. Type adduser -d /home/users/ into the command line.
    1. Example: adduser bob -d /home/users/bob
  2. Type passwd and press return to set a password for the new user.
    1. Type the new password.
    2. Confirm the password.
Method 2 of 4:

Modifying Users

Changing Passwords

  1. Type passwd in the command line.
  2. Enter the new password for the user.
    1. Note: the cursor will not move however your password is being typed.
  3. Confirm the new password.
Method 3 of 4:

Removing Users

  1. Type userdel into the command line to delete a user.
    1. Example: userdel bob
  2. Type userdel -r to also delete their home folder and files.
Method 4 of 4:

Sudo and Su

Terms

  1. sudo: Switch User and Do
    1. Executes a command as root or another use while maintaining your current session.
  2. su: Switch User
    1. Switches your session to another user.

Usage

  1. Type sudo before a command to execute the command as the root user. You will be prompted for a password.
    1. Example: sudo apt-get install telnet
  2. Type sudo before a command to execute the command as another user on the system. You will be promoted for that users password.
    1. Example: sudo bob telnet localhost 22
  3. Type su to switch your command line session to the root user. You will be promoted for a password.
    1. Type logout to switch back.
  4. Type su to switch your command line session to another user. You will be promoted for their password.
    1. Type logout to switch back.
Update 04 March 2020