How Do I Lock a Root User in Linux?
Contents

In order to lock the root account, you have to use the “usermod” command with the “-L” option for “lock” and specify the root account.

How do I restrict a root user in Linux?

The simplest method to disable root user login is to change its shell from /bin/bash or /bin/bash (or any other shell that permits user login) to /sbin/nologin , in the /etc/passwd file, which you can open for editing using any of your favorite command line editors as shown. Save the file and close it.

How do I lock a user in Linux?

UNIX / Linux : How to lock or disable an user account

  1. To lock a users account use the command usermod -L or passwd -l. …
  2. The commands passwd -l and usermod -L are ineffcient when it comes to disable/lock user accounts. …
  3. Expiring an account via use of the 8th field in /etc/shadow (using “chage -E”) will block all access methods that use PAM to authenticate a user.
Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest