Log in Go to the main page Page Discussion History Go to the file list Go to the site toolbox

Sha1sum command

From NetworkCommands


Image:Tux_64x64.png

A command available on most Linux platforms; used to generate and display or check the SHA1 message digest (or checksum) of one or more files.

Contents

Image:Vm-power-on-medium.png Usage Syntax

sha1sum [options] [path/]filename

Common options include;

  • -b - read files in binary mode
  • -t - read files in text mode (this is the default)
  • -c - check against a given list contained within the specified filename
    • --status - only display a status code on success
    • -w - display warnings about improperly formatted checksum file lines

filename is either the file that you wish to generate and display a checksum for, or a file containing a list of checksums and filenames that you wish to check.

Image:Vm-power-on-medium.png Usage Examples

sha1sum test.txt - compute and display the SHA1 checksum for file test.txt

sha1sum --check -w checksums.txt - check the checksums of the files and associated checksums listed in file checksums.txt and warn if lines in checksums.txt are improperly formatted

Image:accessories-text-editor-v2-medium.png Usage Notes

The --status and -w options are only relevant when -c is used.

Here's an example checksum list file:

fdba2b328619f60823dd3254c63309e39a3ce2a3  test.txt
41ef29701323b6103a5404a59f0d994e6d20d63a *test2

The * indicates a binary file

An SAH1 checksum is always 160bits (or 20Bytes.)

Image:accessories-text-editor-v2-medium.png Linux Usage Notes

With most Linux or Unix commands;

  • Brief help can be displayed using the option/keyword: -h or --help, for example: chmod --help
  • A full command manual can be displayed using the man command followed by the command name, for example: man chmod
  • Sometimes 'info' pages are used instead of or to provide more information than man pages; for example: info chmod
  • Version information can be display using the option/keyword: -v or --version, for example: chmod --version


Image:utilities-terminal-medium.png Typical Output

[user@test] ~ # sha1sum test.txt

fdba2b328619f60823dd3254c63309e39a3ce2a3  test.txt

[user@test] ~ # sha1sum test2.txt

41ef29701323b6103a5404a59f0d994e6d20d63a  test2.txt

[user@test] ~ # more checksums.txt

fdba2b328619f60823dd3254c63309e39a3ce2a3  test.txt
41ef29701323b6103a5404a59f0d994e6d20d63a  test2.txt

[user@test] ~ # sha1sum --check -w checksums.txt

test.txt: OK
test2.txt: OK

Image:Folder-medium.png Related Files

sha1sum is normally located here: /usr/bin/sha1sum

Image:icemon-medium.png Related Commands

The md5sum command performs the same function for MD5 message digests.

The OpenSSL dgst command performs the same function while also supporting many other digests.

Image:icemon-medium.png Related Articles

Information on other Linux commands Image:Tux-small.png

Information on other Secure Platform commands

Information on F5 BigIP commands Image:F5-logo-small.png

Information on Cisco commands Image:Cisco-logo-small.png

Information on Vyatta commands Image:Vyatta-logo-small.png

Information on Extreme commands Image:Extreme-logo-small.png

Information on Blue Coat SGOS commands

Information on Nokia IPSO commands


Image:internet-group-chat-small.png We really do appreciate all feedback so please do send your comments, suggestions or corrections to steve#networkstuff.eu (replacing the # with an @)



Site Toolbox:

Personal tools
This page was last modified on 26 August 2008, at 18:46. - This page has been accessed 22 times. - Disclaimers - About NetworkCommands
Powered by MediaWiki