LinuxCommandLibrary

cksum

TLDR

Calculate checksum of file

$ cksum [file.txt]
copy
Calculate checksum of multiple files
$ cksum [file1] [file2]
copy
Calculate from stdin
$ echo "data" | cksum
copy
Use SHA256 algorithm
$ cksum --algorithm sha256 [file.txt]
copy
Verify checksums from file
$ cksum -c [checksums.txt]
copy
Output in base64
$ cksum --base64 [file.txt]
copy

SYNOPSIS

cksum [option]... [file]...

DESCRIPTION

cksum prints CRC checksum and byte count for files. By default uses 32-bit CRC algorithm. Part of GNU coreutils. Used to verify file integrity after transfers.

PARAMETERS

-a, --algorithm name

Select algorithm (crc, md5, sha1, sha256, sha512, etc.)
-c, --check
Read checksums and verify them
-l, --length bits
Digest length in bits
--base64
Output base64-encoded digest
--raw
Output raw binary digest
--tag
BSD-style checksum (default)
--untagged
Reversed style without digest type
-z, --zero
End lines with NUL instead of newline
--ignore-missing
Don't fail for missing files during check
--quiet
Don't print OK for verified files
--status
Silent mode, exit code shows result
-w, --warn
Warn about malformed checksum lines

OUTPUT FORMAT

$ checksum byte_count filename
copy

CAVEATS

CRC32 is not cryptographically secure. Use SHA256 or stronger for security-critical verification. Reads stdin when no file given or file is -.

SEE ALSO

md5sum(1), sha256sum(1), sum(1)

Copied to clipboard