The stackexchange link says "it is not possible to login to the account using a password", but the baeldung link says "anyone can log in to the account without any password".
Both "!" and "!!" being present in the password field mean it is not possible to login to the account using a password.
As it can be read from the documentation of RHEL-4, the "!!" in the shadow-password field means the account of a user has been created, but not yet given a password. The documentation states (possibly erroneously) that until being given an initial password by a sysadmin, it is locked by default.
!! in /etc/shadow’s Password Field
Another symbol that we may encounter in the password field of the /etc/shadow file is the two exclamation points. !! indicates that someone has created a user account but has not given it a password. Therefore, anyone can log in to the account without any password, which is a serious risk.
Which is correct for Ubuntu system?
This is documented in
man 5 shadow
(emphases mine):So, the first
!
means the password is locked and everything after that first!
is the password. Next, if the password is!
that means you can't log in with a password and no, that does not imply that you can login without a password. "Other means" refers to things like root usingsu
to switch to that user. Root wouldn't be prompted for a password anyway, so that is one example of "other means" to log in.We can even test it, easily enough:
Here, I just ran the command
sudo adduser someuser
and pressed Enter to skip all the prompts and leave the password empty. The result is:So we have a user with no password. If I try to log in as that user, I cannot:
So there you go, a password set to
!
(or!!
, since that just means a locked!
) does not allow users to log in without a password. It does, however, let root switch to that user: