Skip to content

sha256sum Command Cheat Sheet

sha256sum computes and verifies SHA256 (256-bit) checksums. It is widely used to verify the integrity of downloaded ISOs and software packages.


Synopsis

sha256sum [OPTION]... [FILE]...

Basic Usage

Calculate Checksum

Prints the SHA256 hash followed by the filename.

sha256sum ubuntu-22.04.iso
# Output:
# a1b2c3d4...  ubuntu-22.04.iso

Hash Multiple Files

sha256sum *.jpg

Verification (-c)

Verify a File

  1. Create a Checksum File:
    sha256sum file.zip > checksums.sha256
    
  2. Verify Later:
    sha256sum -c checksums.sha256
    
    Output:
    file.zip: OK
    

Quiet Verification

Don't print OK for every file, only print errors.

sha256sum -c checksums.sha256 --quiet

Status Only

Don't print anything, just use exit code.

sha256sum -c checksums.sha256 --status
if [ $? -eq 0 ]; then echo "Valid!"; fi

Input from Stdin

echo "password" | sha256sum

Other Hash Algorithms

The usage is identical for these tools: - md5sum (Older, insecure for crypto) - sha1sum (Older, insecure for crypto) - sha512sum (More secure, slower)


Notes

  • Security: SHA256 is generally considered secure for file integrity. For password storage, algorithms like bcrypt or argon2 are preferred (though sha256sum is just a general file utilities tool).