🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

sha256sum Command

Beginner Firewall & Security man(1)

Compute and verify SHA-256 message digests

👁 9 views 📅 Updated: Mar 15, 2026
SYNTAX
sha256sum [OPTION]... [FILE]...

What Does sha256sum Do?

sha256sum calculates and verifies SHA-256 cryptographic hashes (256-bit). SHA-256 is part of the SHA-2 family and is currently the recommended standard for file integrity verification and security.

sha256sum produces a unique 64-character hexadecimal fingerprint. It is computationally infeasible to find two different files with the same hash, making it suitable for security-critical verification.

sha256sum is the standard for verifying software downloads, checking backup integrity, and detecting file tampering.

Options & Flags

OptionDescriptionExample
file Calculate SHA-256 hash sha256sum file.iso
-c Check hashes from file sha256sum -c SHA256SUMS
-b Binary mode sha256sum -b file.bin
--quiet Only show failures sha256sum --quiet -c SHA256SUMS

Practical Examples

#1 Calculate hash

Computes the SHA-256 hash of a file.
$ sha256sum ubuntu.iso
Output: a1b2c3d4e5f6... ubuntu.iso

#2 Verify download

Checks files against their expected SHA-256 hashes.
$ sha256sum -c SHA256SUMS
Output: ubuntu.iso: OK

#3 Hash a string

Calculates SHA-256 of a string.
$ echo -n "password123" | sha256sum
Output: ef92b778bafe... -

#4 Create checksums

Generates a checksum file for all archives.
$ sha256sum *.tar.gz > SHA256SUMS

#5 Multiple files

Calculates hashes for all backup files.
$ sha256sum backup_*.tar.gz

Tips & Best Practices

Always use SHA-256 over MD5: SHA-256 is the current standard for file verification. MD5 is broken for security. sha256sum should be your default.
Verify Linux downloads: Linux distributions provide SHA256SUMS files. Download both the ISO and SHA256SUMS, then run sha256sum -c SHA256SUMS.
Use -n with echo: echo "text" | sha256sum includes a trailing newline. Use echo -n "text" | sha256sum for the exact string hash.

Frequently Asked Questions

How do I verify a download with SHA-256?
Download the SHA256SUMS file, then run sha256sum -c SHA256SUMS in the same directory as the downloaded file.
What is the difference between MD5 and SHA-256?
SHA-256 is cryptographically secure (256-bit). MD5 is broken (128-bit, collisions possible). Always prefer SHA-256.
How do I hash a password?
echo -n "password" | sha256sum. Note: for actual password hashing in applications, use bcrypt or argon2, not raw SHA-256.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →