Creating, Removing, and Managing Users
------------------------------------------------------------------------------------------------------------------------------------------
Adding Users
------------------------------------------------------------------------------------------------------------------------------------------
Adding Users
To add a user, the useradd command can be used.
useradd username
If you want to create a user with it's own home directory, this can be done using the -m flag:
useradd -m username
Additional options:
Comments: When creating a user, you can also opt to add a comment using the -c flag, for example this could be a name:
useradd -c "Daniel"
Additional shell options for user: You're able to specify different shell options that the user will have access to
------------------------------------------------------------------------------------------------------------------------------------------
Passwords
------------------------------------------------------------------------------------------------------------------------------------------
Set Password
Once a user has been created, you can add a password using the passwd command:
passwd username
Once run, you'll be prompted to enter a new password
Changing password
Changing a users password can be done using the passwd command when signed in as that user.
You can either SSH to the server directly using the required user, or access as root and use su- username to access the user. Once accessed, the passwd command can be run alone to change the password:
passwd
Additional Options:
Temporary Password: When setting a password, you're able to set a temporary placeholder password that can be used to log in by the user, upon logging in the user will be prompted to change to a password of their choice. This can be achieved by using the -e flag after setting a password
passwd username #set as temp password
passwd -e #sets password as expired
------------------------------------------------------------------------------------------------------------------------------------------
Deleting Users
------------------------------------------------------------------------------------------------------------------------------------------
Users can be deleted using the userdel command:
userdel username
The above command only removes the user from the system, without removing their home directory.
Remove user and home directory
userdel -r username
------------------------------------------------------------------------------------------------------------------------------------------