If you are using CentOS or RHEL :
If you want to check your user's account status,Run following command :
If your user is locked, it shows
If you are using Debian or Ubuntu and your user is locked, it shows letter L with your username.
If you are using Debian or Ubuntu and your user is unlocked, it shows letter P with your username
If you want to check your user's account status,Run following command :
$ passwd -S "username"
Change the text username with your username whose status you want to check.If your user is locked, it shows
(Password locked.)
If your user is unlocked, it shows(Password set, MD5 crypt.)
List of all locked accounts :$ awk -F: '{ system("passwd -S " $1)}' /etc/passwd | grep " LK "
List of all unlocked accounts :
$ awk -F: '{ system("passwd -S " $1)}' /etc/passwd | grep " PS "
If you are using Debian or Ubuntu :
If you are using Debian or Ubuntu and your user is locked, it shows letter L with your username.
If you are using Debian or Ubuntu and your user is unlocked, it shows letter P with your username
List of all locked accounts :
$ awk -F: '{ system("passwd -S " $1)}' /etc/passwd | grep " L "
List of all unlocked accounts :$ awk -F: '{ system("passwd -S " $1)}' /etc/passwd | grep " P "
Note :
If you are using CentOS 7 and you run following command to list all users with status
passwd -S -a
It gives following error
passwd: bad argument -a: unknown option
Use following command to list all users with their status
If you are using CentOS 7 and you run following command to list all users with status
passwd -S -a
It gives following error
passwd: bad argument -a: unknown option
Use following command to list all users with their status
awk -F: '{ system("passwd -S " $1)}' /etc/passwd
worked for me... thanks
ReplyDeletego with this command
ReplyDeletepasswd -S userid