How to Verify if the Root User Has a Password on Linux Systems

/etc/shadow
file:sudo cat /etc/shadow | grep root
root:$6$abcd1234$abcdefghijklmnopqrstuvwx:18578:0:99999:7:::
If the second field (after root
:
contains a hash, it means the root
user has a password set.
Suppose the second field is empty or contains a special character like !
or \*
, it means the root
user does not have a password set.
Another way to check if the root user has a password is to use the passwd command:
sudo passwd -S root
root P xxxxxx
(where P
stands for Password
): The root
user has a password set. root L xxxxxx
(where L
stands for Locked
): The root
user does not have a password set. root NP xxxxxx
(where NP
stands for No Password
): The root
user does not have a password set.