Understanding /etc/shadow file
Q. Can you explain /etc/shadow file used under Linux or UNIX?
A. /etc/shadow file stores actual password in encrypted format for user's account with additional properties related to user password i.e. it stores secure user account information. All fields are separated by a colon (:) symbol. It contains one entry per line for each user listed in /etc/passwd file Generally, shadow file entry looks as follows (click to enlarge image):
/etc/shadow file fields

(Fig.01: /etc/shadow file fields)
- User name : It is your login name
- Password: It your encrypted password. The password should be minimum 6-8 characters long including special characters/digits
- Last password change (lastchanged): Days since Jan 1, 1970 that password was last changed
- Minimum: The minimum number of days required between password changes i.e. the number of days left before the user is allowed to change his/her password
- Maximum: The maximum number of days the password is valid (after that user is forced to change his/her password)
- Warn : The number of days before password is to expire that user is warned that his/her password must be changed
- Inactive : The number of days after password expires that account is disabled
- Expire : days since Jan 1, 1970 that account is disabled i.e. an absolute date specifying when the login may no longer be used
The last 6 fields provides password aging and account lockout features (you need to use chage command to setup password aging). According to man page of shadow - the password field must be filled. The encrypted password consists of 13 to 24 characters from the 64 character alphabet a through z, A through Z, 0 through 9, \. and /. Optionally it can start with a "$" character. This means the encrypted password was generated using another (not DES) algorithm. For example if it starts with "$1$" it means the MD5-based algorithm was used.
E-mail this to a friend
Printable version
Related Other Helpful FAQs:
- How To: UNIX Add A User To A Group
- Howto: Linux Add User To Group
- Linux Password Cracking: Explain unshadow and john commands ( john the ripper tool )
- Why and How To Customize a UNIX / Linux User Account?
- Move or migrate user accounts from old Linux server to a new Linux server
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: /etc/passwd, /etc/shadow, /etc/shadow fields, /etc/shadow file, account lockout, additional properties, algorithm, encrypted password, etc shadow, etc shadow file, Linux, linux shadow file, maximum number, password field, secure user, setup password, shadow file, ubuntu /etc/shadow, UNIX




April 11th, 2007 at 3:31 pm
What does a symbol of ! or * indicate when placed before this after the user login name . . . after typing cat /etc/shadow?
April 11th, 2007 at 6:16 pm
! or * indicate that the user will not be able to use a unix/linux password to log in. In other words user login will be disabled.
HTH
May 29th, 2007 at 3:56 pm
Nice to get this information here, couldn’t understand it when our teacher taught it in class
August 1st, 2007 at 8:26 am
If a user changes his password (using passwd command), how is the shadow file updated to include the new passwd? I mean, doesn’t the root/admin only have write permissions to this file?
August 1st, 2007 at 12:07 pm
passwd command has SUID (Saved User ID) enabled. When passwd command executed the effective user id (EUID) that is in force at the time is copied to the saved user id (i.e. root). Using this technique a normal user can update his/her password.
August 14th, 2007 at 9:29 am
username:!!: …. or
username:!!$1$MvGJq5Nq$ersjw/IaU90l.n5sB/FFP1: …
I tried this on Linux machine and !! appeared after passwd -l username command - locking password.
After passwd -u username - unlock, !! disappeared again.
So this means that user cannot log in, so it is blocked, but I am not sure about all those rpm, nscd, nfsnobody and so on users.. they have only :!!: in password field in ect/shadow file. These users cannot log in, but are they entirely blocked?
November 14th, 2007 at 9:15 pm
The root user can still access accounts with blocked passwords, using su, but only if those accounts have a shell enabled in /etc/passwd (if the shell is /sbin/nologin, even root cannot access the account). I don’t know if there’s a difference between !! and * in the password field of the shadow file, though.
November 15th, 2007 at 8:54 pm
Is it possible to have etc/shadow file where all the passwords are encrypted however one password is simply a recognizable word?
November 15th, 2007 at 9:11 pm
one password is simply a recognizable word?
Noop.
March 3rd, 2008 at 2:11 pm
can any one make answer more clear how passwd changes the password although /etc/shadow has permissions ‘r——–’ with root as owner.
March 13th, 2008 at 11:58 am
If there is an account in the etc/shadow file and the account does not have an equivalent in the etc/passwd file? Will the account work for login?
April 4th, 2008 at 9:05 am
@sunil
heya mate. the passwd command can only be run by root or as a root (using sudo). The root can access (including read and write) to any file even if he doesnt have the permissions. Thats why as a root, the /etc/shadow can be changed.
You can call it perks of the job…
HTH
April 23rd, 2008 at 10:21 pm
sunil-
passwd command can be run by any user. when root runs it, they dont need to specify an old password to change it.
July 16th, 2008 at 5:04 am
Hey guys,
Can you please tell me if
1. \”!!\” means that the password is expired and the user will not be able to login?
2. \”*\” means that the userid is locked?
July 18th, 2008 at 9:00 am
the passd command is both SUID and SGID — these stand for Set User ID and Set Group ID. See permissions below;
% ls -l /usr/bin/passwd
54 -r-sr-sr-x 1 root sys 27228 Aug 16 2007 /usr/bin/passwd
Just to clarify the perms –
* user perms (root) - read, setuid on execute
* group perms (sys) - read, setgid on execute
* anyone perms - read and execute
So, when anyone runs the passwd command, they will effectively be running it as the root user and the sys group.
Although the permissions of passwd are read (no write), root does have the ability to force write on any file on a UNIX system (locally mounted).
That is why when you run the passwd command, you effectively become root and the shadow file is updated.
Hope that helps.