Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I check the SHA1 hash of a file?

share|improve this question
up vote 87 down vote accepted


Print or check SHA1 (160-bit) checksums. With no FILE, or when FILE is -, read standard input.

sha1sum {file}

If you want to send the file together with its sha1sum output redirect the output to a file:

sha1sum {file} > {file}.sha1

Send both files and the other party can do a...

sha1sum -c {file}.sha1

It should show OK if the sha1 is correct.

share|improve this answer
Great! But how do you run sha1sum -c when {file}.sha1 contains only the hash and no filename (as often to be downloaded from various corners of the Internet)? I came up with for f in *.sha1; do echo "$(cat $f) ${f/.sha1/}"; done | sha1sum -c (note double space), but this must be much simpler. – Piotr Findeisen Oct 17 '13 at 1:45
or shasum -- the default SHA is (if I am correct) SHA1. Also you set it with -a, --algorithm option: shasum -a 1 – xealits Sep 23 '15 at 15:05
@PiotrFindeisen - The output of sha1sum is <hash> <full file path> so there is enough information for sha1sum -c to know which file it's to verify – MYou Jan 5 at 18:41

Without creating local file:

$ sha1sum filename

8dd10000eb1b768800000e1d2fe1c3100005d2dc *filename

For checking, go to the directory that contains filename and run this command:

echo "8dd10000eb1b768800000e1d2fe1c3100005d2dc *filename" | sha1sum -c -
share|improve this answer
Thanks, though I don't think you should have the * in there. Here's a concrete example: echo 'b78bb50bdac5ec8c108f34104f788e214ac23635' | sha1sum -c - That will check a file name in the current directory. – Luke Apr 8 at 6:57

Its very simple.

Nagivate to the terminal and key in

sha1sum  filename

to confirm a sha1 hash use,

sha1sum -c filename
share|improve this answer

What are you people talking about? Yes, I get the concept behind sha1sum, but the info above is confusing to say the best. First, Ubuntu does not seem to have sha1sum files - just strings on a web page such as this for Mate 16.04 Beta 1:

bfba577970d573e0ba5095fbb72787de97f88b4b *ubuntu-mate-16.04-beta1-desktop-amd64.iso
efcbbc70b10173cea203df30396d0848ba8fa0d8 *ubuntu-mate-16.04-beta1-desktop-i386.iso
8563fec4d66bce851b0800f5ac746f38e4041a6a *ubuntu-mate-16.04-beta1-desktop-powerpc.iso

To check the integrity of a downloaded .iso, one opens the terminal program, does "cd Downloads", then sha1sum . After a bit, the terminal will produce a hash such as

efcbbc70b10173cea203df30396d0848ba8fa0d8  ubuntu-mate-16.04-beta1-desktop-i386.iso

Next, we have to go to the web page and compare the strings to verify that the verification works. Not nearly as easy as it could be.


share|improve this answer

protected by Eric Carvalho Feb 29 at 21:25

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.