File integrity means a file is still what you expect. Checking it helps you notice accidents, failed updates and unwanted changes on your own hosts.
Cryptographic hashes
A hash function turns file contents into a short fixed-length value. Change one byte and the value changes completely.
$ echo 'port=80' > app.conf
$ sha256sum app.conf > app.sha256
$ sha256sum -c app.sha256
app.conf: OK
$ echo 'debug=true' >> app.conf
$ sha256sum -c app.sha256
app.conf: FAILED
sha256sum: WARNING: 1 computed checksum did NOT matchUse SHA-256 or stronger. MD5 and SHA-1 are no longer suitable against deliberate tampering.
Content is not everything
A hash covers contents only. Ownership and permissions can change while the hash stays the same:
$ stat -c '%a %U:%G %y %n' app.conf
644 alice:alice 2026-03-03 09:20:11.000000000 +0000 app.confModification times can be set by a user with access, so do not rely on them alone.
Verify packaged files
Your package manager records information about installed files.
sudo rpm -V openssh-server # Fedora, RHEL
sudo dpkg -V openssh-server # Debian, UbuntuNo output means no differences were found by the checks performed. rpm -V prints letters such as S for size, 5 for digest, M for mode and T for modification time, with c marking a configuration file. dpkg -V checks much less, mainly file contents. An edited configuration file is often expected.
Know the limits
A checksum only helps if the reference is trustworthy. If someone can change both the file and its recorded hash, the check passes. Keep references on read-only or separate storage. A system with a compromised root account can also give false answers, including from the package database. For stronger assurance, check from trusted boot media.
A mismatch tells you that something differs, not who changed it or why. Compare with your change records.
Try it
In a temporary directory, repeat the sha256sum example. Then run chmod 600 app.conf after restoring it, and see that the hash check still passes while stat shows the new mode. See the permissions lab.
Check your understanding
File Integrity
All 3 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.