Session and utilities

The sha1sum command

Computes the SHA-1 digest of files to check that they are not damaged or altered. It is useful to verify downloads, as long as the source publishes the checksum.

Syntax

sha1sum [opciones] [archivo...]Try it in the terminal →

Most useful options

-cReads a checksum file and verifies each file, printing OK or FAILED
--ignore-missingWith -c, ignores the files listed that do not exist on disk
-bReads in binary mode and marks each name with an asterisk. It only has an effect on Windows, where it avoids converting line endings

Copy-ready examples

$ sha1sum hola.txtcomputes the digest of a file. Each line is the sum, two spaces and the name.

Example output

63bbfea82b8880ed33cdb762aa11fab722a90a24  hola.txt
$ sha1sum hola.txt > SHA1SUMS && sha1sum -c SHA1SUMSsaves 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

MessageCauseFix
sha1sum: nonexist: No such file or directoryThe file does not exist or the name is misspelled.Check the path with ls before computing the sum.
sha1sum: WARNING: 1 computed checksum did NOT matchThe 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.
sha1sum: bad.txt: no properly formatted SHA1 checksum lines foundThe checksum file does not have the expected format, for example because it is an HTML page or it is empty.Open the file and check that each line has a sum, two spaces and a name.
sha1sum: WARNING: 1 listed file could not be readA file in the list does not exist or cannot be read.Restore the file or remove it from the checksum list. --ignore-missing skips it.

Typical mistakes

  • SHA-1 does not withstand an attacker: deliberate collisions have been published. To validate sensitive downloads use sha256sum.
  • The sum only proves the file is identical to the original list. If an attacker changes the file and the list together, the check passes.
  • On Windows, Git Bash marks the name with an asterisk because it uses binary mode. That asterisk is not part of the name and does not change the hash.

Differences from similar commands

  • sha256sum: the same idea with SHA-256, which still resists deliberate collisions. Use it when the checksum must withstand an attacker.
  • md5sum: computes MD5, an older algorithm that is also broken for cryptographic use. It only detects accidental damage.

FAQ

What is a SHA-1 sum?

A fixed-size fingerprint of 40 hexadecimal characters that changes completely if a single byte of the file changes.

How do I check a download against the published sum?

Run sha1sum on the file and compare the output with the one the site publishes. If they only offer SHA-256, use sha256sum.

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