Session and utilities
The md5sum command
Computes the MD5 hash of files to check that they have not changed.
Most useful options
-c, --checkReads a checksum file and verifies each file, printing OK or FAILED--ignore-missingWith -c, skips without reporting the listed files that do not exist--quietWith -c, does not print OK for each correct file, only the failures--statusWith -c, prints nothing: only the exit code, 0 if everything matches--strictWith -c, exits with an error if any line of the list is badly formatted-b, --binaryReads in binary mode. On GNU systems it does not change the result compared to text mode-z, --zeroEnds each line with a null byte instead of a newlineCopy-ready examples
$ md5sum /etc/passwdhash of a system file.$ md5sum /etc/passwd /etc/groupseveral hashes at once, one line per file.$ printf 'hola\n' > hola.txt && md5sum hola.txteach line is the sum, two spaces and the name.Example output
916f4c31aaa35d6b867dae9a7f54270d hola.txt
$ md5sum hola.txt > sumas.md5 && md5sum -c sumas.md5saves the sum and checks it later. OK confirms the file is unchanged.Example output
hola.txt: OK
You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| md5sum: noexiste.txt: No such file or directory | The file does not exist or the name is misspelled. | Check the path with ls before computing the hash. |
| md5sum: dir1: Is a directory | You passed a folder. md5sum only computes sums of files. | Name a specific file inside the folder. |
| md5sum: WARNING: 1 computed checksum did NOT match | The file has changed since the sum was generated: it is damaged, edited or another version. The line shows as FAILED. | Download it again from the official source and compare again. |
Typical mistakes
- Any change, even a line break, changes the hash.
- The manual itself warns against using MD5 for security purposes: to validate sensitive downloads, use sha256sum.
- A sum only proves the file is identical to the list. If someone changes the file and the list together, the check passes.
Differences from similar commands
FAQ
Is MD5 still useful?
To detect accidental changes, yes. For security, no: use SHA-256 or similar.
What does the asterisk in front of the name mean?
It shows how the file was read: '*' is binary mode and ' ' is text mode. On GNU/Linux both modes give the same sum.
What does FAILED open or read mean?
The file listed could not be opened or read: it does not exist, you lack permission or it is a folder. With --ignore-missing it is skipped if it is only missing.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course