Skip to content

Linux Foundations / Manage a Linux host ยท Step 4 of 50

Lesson: /etc/shadowSwitch
โ† Linux Foundations

System administration

/etc/shadow

Understand how /etc/shadow stores password hashes and password ageing rules.

/etc/shadow holds the password hashes of local accounts, along with rules about how old a password may be. Ordinary users cannot read it.

Who can read it

$ ls -l /etc/shadow
-rw-r----- 1 root shadow 895 Mar 10 09:00 /etc/shadow

This is the Debian and Ubuntu style. Other distributions may use a different group or a stricter mode.

The fields

A line has nine colon-separated fields. The example hash is shortened and not real:

maya:$y$j9T$abc...$def...:20500:0:99999:7:::
  1. login name
  2. password hash
  3. date of last change, in days since 1 January 1970
  4. minimum days between changes
  5. maximum password age in days
  6. warning days before expiry
  7. inactivity period after expiry
  8. account expiry date
  9. reserved

Reading the password field

A hash is a one-way result: the system hashes what you type and compares. The prefix names the method, for example $y$ for yescrypt and $6$ for SHA-512. Which one is the default depends on distribution and version.

A field starting with ! or * means no password will match. A ! placed before a hash is how an account password is locked. This blocks password login only, so an SSH key may still work. An empty field is dangerous: it can allow access with no password.

Ageing with chage

You can view the rules without reading the file by hand:

$ chage -l maya
Last password change                    : Feb 16, 2026
Password expires                        : never
Password inactive                       : never
Account expires                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

On Debian and Ubuntu you can view your own account without sudo; elsewhere you may need it, and other accounts always need privilege. To force a change at next login:

$ sudo chage -d 0 maya

Change passwords with passwd, not by editing the file. For manual repairs, sudo vipw -s locks it safely.

Try it

$ ls -l /etc/shadow
$ chage -l "$USER"
$ sudo grep "^$USER:" /etc/shadow

Count the fields and find the method prefix. Treat the output as secret: never paste a real hash into chats, tickets or screenshots, because attackers can try to guess passwords against it offline.

Check your understanding

/etc/shadow

All 5 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.