Which command is used to lock a user account in Linux?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Boost your Linux skills with the CompTIA Linux+ Certification Exam simulator. Engage with multiple choice questions and detailed feedback. Master Linux concepts and prepare for your exam with confidence!

The command that is used to lock a user account in Linux is the passwd command. When you want to lock a user account, you can use it with the -l (lowercase L) option, such as passwd -l username. This effectively disables the user's ability to log in by placing an "!" in front of the user's password hash in the /etc/shadow file, thereby blocking the authentication process.

While usermod does have capabilities to modify user accounts, it is typically not directly associated with locking accounts. It can be used to change various properties of a user, including their home directory or shell, but does not lock accounts by itself.

userdel is primarily for deleting user accounts, and groupmod is used for modifying existing groups. Neither of these commands relates to locking an account.

Thus, passwd is the command specifically designed for managing user passwords and account statuses, making it the correct choice for locking a user account in Linux.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy