sha1sum - Linux Command - Unix Command

The 'sha1sum' command both creates and verifies SHA1 checksums

Man using laptop computer
PhotoAlto/Sigrid Olsson / Getty Images

Use the sha1sum utility in Linux to print or check SHA1 (160-bit) checksums.

Synopsis

The command takes the following general forms:

sha1sum [OPTION] [FILE]...
sha1sum [OPTION] --check [FILE]  

Options

Modify the command's output using the following flags:

  • -b--binary: Read files in binary mode (default on DOS/Windows).
  • -c--check: Check SHA1 sums against given list.
  • -t--text: Read files in text mode (default).
  • --status: Don't output anything, status code shows success.
  • -w--warn: Warn about improperly formated checksum lines.
  • --help: Display this help and exit.
  • --version: Output version information and exit.

How the Program Works

sha1sum output

The sums are computed as described in FIPS-180-1.

To create an SHA1 checksum for a file, run sha1sum filename > filename.sha1. This process writes to the output of sha1sum to a file ending with an .sha1 extenstion.

To verify that the file's checksum matches, use the -c flag upon that outputted checksum. For example, sha1sum -c filename.sha1. If the file verifies correctly, you'll receive an OK response. The file you're checking, as well as the checksum file, must be in the same directory.