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
✗ Incorrect
useradd is used to create new user accounts.
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
✗ Incorrect
The -r option deletes the user account and the user's 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
✗ Incorrect
The -d option sets the home directory path.
Which command deletes a user account but keeps the home directory?
Auserdel username
Buserdel -r username
Cuseradd username
Dusermod -d username
✗ Incorrect
userdel username deletes the user but leaves the home directory intact.
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
✗ Incorrect
Backing up files prevents data loss since -r deletes user files.
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.
Practice
(1/5)
1. What does the useradd command do in Linux?
easy
A. Lists all users on the system
B. Deletes an existing user account
C. Changes the password of a user
D. Creates a new user account
Solution
Step 1: Understand the purpose of useradd
The useradd command is used to create new user accounts on a Linux system.
Step 2: Differentiate from other commands
userdel deletes users, passwd changes passwords, and listing users is done by other commands like cat /etc/passwd.
Final Answer:
Creates a new user account -> Option D
Quick Check:
useradd = create user [OK]
Hint: Remember: add means create, del means delete [OK]
Common Mistakes:
Confusing useradd with userdel
Thinking useradd lists users
Mixing useradd with password commands
2. Which of the following is the correct syntax to create a user with a home directory?
easy
A. useradd -r username
B. useradd username
C. useradd -m username
D. userdel -m username
Solution
Step 1: Identify the option for creating home directory
The -m option with useradd creates the user's home directory.
Step 2: Check other options
-r is for system users or removing files with userdel, so it is incorrect here.
Final Answer:
useradd -m username -> Option C
Quick Check:
-m means make home directory [OK]
Hint: Use -m with useradd to create home folder [OK]
Common Mistakes:
Using userdel instead of useradd
Forgetting the -m option for home directory
Using -r option with useradd
3. What will be the result of this command sequence?
useradd -m alice
userdel alice
medium
A. User alice is deleted but home directory remains
B. User alice and home directory are deleted
C. User alice is created but deletion fails
D. Syntax error occurs
Solution
Step 1: Create user alice with home directory
useradd -m alice creates user alice and a home folder.
Step 2: Delete user alice without -r option
userdel alice deletes the user but does not remove the home directory unless -r is used.
Final Answer:
User alice is deleted but home directory remains -> Option A
Quick Check:
userdel without -r keeps files [OK]
Hint: userdel needs -r to remove home directory [OK]
Common Mistakes:
Assuming home directory is deleted without -r
Thinking userdel fails without -r
Confusing useradd options with userdel
4. You run userdel -r bob but get an error saying user bob does not exist. What is the likely cause?
medium
A. The home directory is missing
B. User bob was never created
C. You need to use useradd to delete users
D. The -r option is invalid with userdel
Solution
Step 1: Understand the error message
The error says user bob does not exist, so the system cannot delete a non-existent user.
Step 2: Check command validity
userdel -r bob is valid syntax to delete user and home directory, so the error is not due to syntax.
Final Answer:
User bob was never created -> Option B
Quick Check:
User must exist before deletion [OK]
Hint: Check if user exists before deleting [OK]
Common Mistakes:
Thinking -r is invalid option
Trying to delete users with useradd
Assuming home directory missing causes error
5. You want to create a script that adds a user with a home directory and then deletes the user along with all their files. Which commands should you use in order?
hard
A. useradd -m username; userdel -r username
B. useradd username; userdel username
C. userdel -r username; useradd -m username
D. userdel username; useradd username
Solution
Step 1: Add user with home directory
Use useradd -m username to create the user and their home folder.
Step 2: Delete user and all files
Use userdel -r username to remove the user and their home directory and files.
Final Answer:
useradd -m username; userdel -r username -> Option A
Quick Check:
Add with -m, delete with -r for files [OK]
Hint: Add with -m, delete with -r to remove files [OK]
Common Mistakes:
Deleting before adding user
Forgetting -m when adding user
Forgetting -r when deleting user
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.