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
administrator:$1$bHWjtMVG$Ga4FH3DuhkMFGNMRAxorj/:17146:0:99999:7:::
enterprisedb:*:17146:0:99999:7:::
k2admin:$1$3StNGVub$CbF2zqVCHD.8VkqeBSvvT/:17175:0:99999:7:::
k2administrator:$1$jVkaxZ9B$Q62MGwOfq/Je2wHP66zIm0:17175:0:99999:7:::
k2admin1:!$1$Y9Glu8aM$4q7nK6/NnuGUgilMMhiUX1:17175:0:99999:7:::

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