Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 62 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

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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