Lock Linux account

After creating a user account, some time later we have to lock the account. Account lock or unlock can be done with usermod command.

Examples:Create User account and change the password

[root@localhost ~]# useradd k2admin1
[root@localhost ~]# passwd k2admin1
Changing password for user k2admin1.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Lock the user account

[root@localhost ~]# usermod -L k2admin1

Verify the account status

If Exclamation mark is there in /etc/shadow file, then it is locked. Otherwise unlocked. In the last line of below output exclamation(!) is there.

[root@localhost ~]# tail -5 /etc/shadow

For more information, go through To check the status of Linux account

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools
Skip to toolbar