0
0
Linux CLIscripting~5 mins

useradd and userdel in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the useradd command do in Linux?
The useradd command creates a new user account on the system. It sets up the user's home directory, default shell, and other settings.
Click to reveal answer
beginner
What is the purpose of the userdel command?
The userdel command deletes a user account from the system. It can also remove the user's home directory and files if used with the right options.
Click to reveal answer
intermediate
How do you create a user with a specific home directory using useradd?
Use useradd -d /path/to/home username. The -d option sets the home directory for the new user.
Click to reveal answer
intermediate
What option with userdel removes the user's home directory and mail spool?
The -r option deletes the user's home directory and mail spool along with the user account: userdel -r username.
Click to reveal answer
beginner
Why should you be careful when using userdel -r?
Because it permanently deletes the user's home directory and files. If important data is there, it will be lost. Always back up if needed.
Click to reveal answer
Which command creates a new user account in Linux?
Auseradd
Buserdel
Cusermod
Dpasswd
What does the -r option do with userdel?
AResets the user password
BRemoves the user account only
CRenames the user account
DRemoves the user account and home directory
How do you specify a custom home directory when adding a user?
Auseradd -h /home/custom user
Buseradd -d /home/custom user
Cuseradd -m /home/custom user
Duseradd --home /home/custom user
Which command deletes a user account but keeps the home directory?
Auserdel username
Buserdel -r username
Cuseradd username
Dusermod -d username
What should you do before running userdel -r?
ANothing, it is safe always
BChange the user's password
CBack up important user files
DRestart the system
Explain how to add a new user with a custom home directory and then delete that user including their files.
Think about the options that control home directory and file removal.
You got /2 concepts.
    Describe the risks of using userdel -r and how to avoid them.
    Consider what happens to user data when deleting accounts.
    You got /3 concepts.