Linux – What does it mean a ! before the username field in /etc/passwd

linuxpasswordrhelusers

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:

!user:x:0:0:user:/home/user:/bin/bash

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

Best Answer

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.

Related Question