How do I check if my root password (login) is disabled?
You can use the passwd
command:
# passwd -S
root P 11/04/2014 -1 -1 -1 -1
# passwd -l root
passwd: password expiry information changed.
# passwd -S
root L 11/04/2014 -1 -1 -1 -1
# passwd -d root
passwd: password expiry information changed.
# passwd -S
root NP 11/04/2014 -1 -1 -1 -1
From man 1 passwd
:
-S, --status
Display account status information. The status information consists
of 7 fields. The first field is the user's login name. The second
field indicates if the user account has a locked password (L), has
no password (NP), or has a usable password (P). The third field
gives the date of the last password change. The next four fields
are the minimum age, maximum age, warning period, and inactivity
period for the password. These ages are expressed in days.
The data shown is stored in /etc/shadow
, the file which holds the encrypted passwords.
For example, after each of the above passwd
commands, the states were:
1:root:$6$............long hash...............::::::
1:root:!$6$........same long hash.............:16478::::::
1:root::16478::::::
One possibility is to look into /etc/passwd by entering
grep root /etc/passwd
It should show a line starting like root:x: ......
where the x indicates that encrypted passwords are stored in the shadow file. If this is the case, we look into it by running
sudo grep root /etc/shadow
(shadow file needs sudo to be opened!) You should get a line beginning like the following as a result root:!: ......
where the !
or a *
signalize that the account is disabled. Any other value (not beginning with ! or *) after root:
would indicate a working password.