After doing some googling I could not find why in the /etc/passwd

shows a ! at the beginning of the line.

It looks like this:


any ideas? my only guess is that perhaps the user no longer exist.

  • How do you login as root ? – don_crissti Nov 19 '15 at 18:38
  • @don_crissti is not the only user. obviously not with that one. – user2171775 Nov 19 '15 at 18:51

This essentially does nothing more than changing the username to !user, so if you try to login as user you will get:

No passwd entry for user 'user'

as the username has been changed to !user.

Now if you change the /etc/shadow too and set the username as !user, then you can login as the user !user using the same password used for user.

If you want to block a user from logging in using password, you should add a ! to the password field of /etc/shadow or better use passwd -l command.

  • @user2171775 Glad I could help :) – heemayl Nov 23 '15 at 16:06

From wikipedia :

"!" – the account is password locked, user will be unable to log-in via password authentication but other methods (e.g. ssh key) may be still allowed)[7]

In addition, it also seems that the significance of ! in /etc/passwd can vary depending on the position(colon) which it is. At this link they provide an example of entries where the ! is located in the password field, like this :


and they explain that

If a user ID has a password, then the password field will have an ! (exclamation point).

  • well I went to the wikipedia and that information applies to the /etc/shadow not the /etc/passwd – user2171775 Nov 19 '15 at 18:29
  • The OP isn't asking about a '!' in the password field, that's well documented. They're asking about the '!' at the beginning of the line. – David King Nov 19 '15 at 18:34
  • if it isn't useful can be removed, heemayl provided a nice answer – lese Nov 19 '15 at 18:38

The fact that the entry still exists in the /etc/passwd file means the user still exists. Placing a '!' at the beginning of the line is, as far as I know, not a standard procedure but it would have the effect of disabling logins for that user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.