Learn about difference between /etc/passwd and /etc/shadow files in Linux system. 9 points to understand comparison of these two files.
Its one of the Linux beginners interview question explain difference between /etc/passwd and /etc/shadow files or compare passwd and shadow file in Linux. Basically both files serves different purposes on system so its not completely logical to compare them but still if you want to we have this article for you explaining /etc/passwd vs /etc/shadow.
Before reading ahead, if you are not sure about these files read our articles explaining these files field by field.
Difference between /etc/passwd and /etc/shadow
- File formats are same i.e. fields separated by colons & new row for each user. But number of fields are different. passwd file has 7 fields whereas shadow file has 8 fields.
- All fields are different except the first one. Its same for both files and is username.
- /etc/passwd file aims at user account details while /etc/shadow aims at user’s password details.
- passwd file is world readable. shadow file can only be read by root account.
- User’s encrypted password can only be stored in /etc/shadow file.
- pwconv command is used to generate shadow file from passwd file if it doesnt exist.
- passwd file exist by default when system is installed.
- passwd file information is more of a static (home directory, shell, uid, gid which hardly changes)
- shadow file information changes frequently since its related to password and user password changes frequently (if not, password policies are loosely defined!)