What is `/etc/shadow` used for?

QuestionsQuestions8 SkillsProDec, 19 2025
0101

The /etc/shadow file is used to securely store encrypted user passwords and password aging information.

While /etc/passwd stores general user information (like UIDs and home directories), it is world-readable (anyone can look at it). For security reasons, the actual passwords were moved to /etc/shadow, which is strictly protected.

Key Purposes:

  1. Security (Password Hiding): Only the root user (or users with sudo) can read this file. This prevents regular users from even seeing the encrypted hashes of other people's passwords, making "offline" cracking attempts much harder.
  2. Encrypted Passwords: It stores the password in a "hashed" format (usually using strong algorithms like SHA-512).
  3. Password Aging Policy: It stores metadata about the password, such as:
    • When the password was last changed.
    • The minimum/maximum number of days before a password must be changed.
    • When the account will expire.
    • Warning periods before a password expires.

Comparison:

Feature /etc/passwd /etc/shadow
Visibility Readable by everyone Readable only by root/sudo
Content User account details Encrypted passwords & aging
Password field Shows an x Shows the actual hash

If you try to view it as a normal user with cat /etc/shadow, you will get a "Permission denied" error. You must use sudo cat /etc/shadow to see its contents!

0 Comments

no data
Be the first to share your comment!