csum - Linux
Overview
csum is a versatile Linux command that calculates and verifies checksums for files and standard input. It can generate different checksum types, including CRC32, MD5, SHA1, and SHA256, enhancing the integrity and authenticity of data.
Syntax
csum [OPTIONS] [FILE]...
csum -r [OPTIONS] DIRECTORY
Options/Flags
- -a, –algorithm ALG: Specify checksum algorithm (
crc32
,md5
,sha1
,sha256
). Defaults tocrc32
. - -c, –check: Verify checksums stored in input files.
- -e, –quiet: Suppress informational output.
- -h, –help: Display help information.
- -l, –list: Print checksums in a textual format (default).
- -p, –pipe: Pipe standard input to csum.
- -o, –output FILE: Save checksums to specified file.
- -r, –recursive: Calculate checksums for all files in a directory recursively.
- -s, –status: Print status information for each file.
- -v, –verbose: Print additional information.
- -w, –raw: Print checksums in a raw binary format.
Examples
Generate Checksums for Files
csum file1 file2 file3
Verify Checksums for Files
csum -c file1.crc file2.crc file3.crc
Calculate Checksums Recursively
csum -r directory
Pipe Checksums to Another Command
csum -p | grep sha256
Save Checksums to a File
csum -o checksums.txt file1 file2
Common Issues
No File Specified
If no files are provided, csum will process standard input instead.
Invalid Algorithm
If an invalid checksum algorithm is specified, csum will exit with an error message.
File Permission Denied
Ensure that you have appropriate file permissions to read or write the files being processed.
Integration
csum can be integrated with other commands for advanced tasks. For instance, you can use it to:
- Verify the integrity of downloaded files using
wget
:
wget -O file http://example.com/file && csum -c file.crc
- Compare checksums for file backups using
rsync
:
rsync -av --checksum=crc32 source/ destination/ && csum -c source/*crc
Related Commands
- cksum: Calculates CRC32 checksums only.
- md5sum: Calculates MD5 checksums only.
- sha1sum: Calculates SHA1 checksums only.
- sha256sum: Calculates SHA256 checksums only.