LFCA practice question 4 of 15

Which of the following commands can be used to lock a user’s account so that they cannot log into a Linux server without removing any files, folders, or data?

Full set: 60 questions

Domain System Administration Fundamentals

Answer options
A: lock
B: usermod Correct answer
C: userdel
D: chmod
Correct Answer:
B. usermod
Explanation

The usermod command is the standard utility for modifying an existing user account's properties. The -L (or --lock) option is specifically designed to lock a user's password. This action prepends an exclamation mark (!) to the beginning of the encrypted password hash in the /etc/shadow file, which prevents the user from authenticating via password. This method effectively locks the account from login without deleting the user's account, home directory, or any associated data. The account can be unlocked later using the usermod -U command.

Why Incorrect

A. lock: This is not a standard Linux command for locking user accounts. Utilities with this name are typically for file locking, not user account management.
C. userdel: This command is used to delete a user account. Using it would violate the requirement that no files, folders, or data be removed.
D. chmod: This command changes the permissions of files and directories. It does not have a function to lock a user's ability to log in.

References

1. The Linux man-pages project, usermod(8) Manual Page: The official man page for usermod describes the -L, --lock option: "Lock a user's password. This puts a '!' in front of the encrypted password, effectively disabling the password." (Source: man usermod(8))

2. Red Hat Enterprise Linux 9 Documentation, "Configuring basic system settings", Chapter 10. Managing local users and groups, Section 10.5. Modifying a user account: This official vendor documentation states, "To lock a user account, use the usermod utility with the -L or --lock option... This command prevents the user from logging in by changing the password to an invalid value."

3. Ubuntu Server Guide, "User Management", Section "Locking and Unlocking Users": This official distribution guide provides the following command and explanation: "To lock a user’s account, the usermod command can be used with the -L option... This will prevent the user from logging in."

Scroll to Top