Study for the TestOut Linux Pro Exam with our engaging quiz. Prepare using our flashcards and comprehensive multiple choice questions, each with hints and explanations to help you succeed. Get ready for your Linux certification today!

Practice this question and more.


What command is used to delete a user and their home directory?

  1. userdel -r

  2. usermod -r

  3. userdel -f

  4. deactivate user

The correct answer is: userdel -r

The command used to delete a user and their home directory is `userdel -r`. When you use `userdel` to remove a user account from the system, the `-r` option specifically instructs the command to also remove the user's home directory and its contents. This is a crucial feature because simply deleting the user account without this option would leave behind the user's files, which could take up unnecessary space and create potential security issues. In comparison, the other commands provided do not serve the same purpose. The `usermod` command is utilized for modifying user accounts, not for deleting them. The option `userdel -f` forcefully deletes a user account, but it does not remove the user's home directory unless combined with the `-r` option. The option "deactivate user" is not a recognized command in standard Linux systems for removing users. Hence, `userdel -r` is the correct answer for ensuring that both the user account and their associated home directory are completely removed from the system.