Learn about the difference between /etc/passwd and /etc/shadow files in the Linux system. 9 points to understand the comparison of these two files.
Its one of the Linux beginners interview question explain the difference between
/etc/shadow files or compare passwd and shadow files in Linux. Basically both files serve different purposes on the system so it’s not completely logical to compare them but still if you want to we have this article for you explaining
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 the same i.e. fields separated by colons & new row for each user. But the number of fields is different. passwd file has 7 fields whereas the shadow file has 8 fields.
- All fields are different except for the first one. It’s the same for both files and is the username.
- /etc/passwd file aims at user account details while /etc/shadow aims at the user’s password details.
- the passwd file is world-readable. shadow file can only be read by the root account.
- The user’s encrypted password can only be stored in /etc/shadow file.
- pwconv command is used to generate a shadow file from the passwd file if it doesn’t exist.
- passwd file exists by default when the 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!)