Which command deletes a user and their home directory?

Prepare for the Red Hat Certified Systems Admin Exam EX200. Enhance your skills with interactive quizzes, flashcards, and detailed explanations. Ace your certification exam today!

Multiple Choice

Which command deletes a user and their home directory?

Explanation:
The main concept here is removing a user and their home directory in one step. On Red Hat systems, you do that with the userdel command using the -r option. The base userdel command deletes the account from the system (entries in /etc/passwd, /etc/shadow, etc.), but the home directory is left behind unless you tell it to remove it. Adding -r instructs userdel to also remove the user’s home directory and the mail spool, giving you a clean slate in one operation. That's why the best choice is to run: userdel -r <user>. Other commands like deluser or removeuser are not standard on RHEL and don’t perform the same action here, which is why they aren’t the right pick for this operating system. If the user has running processes, you’d want to terminate them first to avoid issues during deletion.

The main concept here is removing a user and their home directory in one step. On Red Hat systems, you do that with the userdel command using the -r option. The base userdel command deletes the account from the system (entries in /etc/passwd, /etc/shadow, etc.), but the home directory is left behind unless you tell it to remove it. Adding -r instructs userdel to also remove the user’s home directory and the mail spool, giving you a clean slate in one operation. That's why the best choice is to run: userdel -r .

Other commands like deluser or removeuser are not standard on RHEL and don’t perform the same action here, which is why they aren’t the right pick for this operating system. If the user has running processes, you’d want to terminate them first to avoid issues during deletion.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy