Home > File & Directory Management > cksum

cksum: Calculate and Verify File Checksums

The cksum command calculates and outputs the CRC (Cyclic Redundancy Check) checksum and byte count of a file. This value is used to verify the integrity of a file or to ensure that a transmitted file has not been corrupted.

Overview

cksum calculates the CRC checksum and byte count of a specified file and outputs it to standard output. This value is used as an indicator to quickly check if the file's content has changed, and it is primarily used for integrity verification after file transfer.

Key Features

  • CRC32 checksum calculation
  • File byte count output
  • File integrity verification
  • Standard input processing capability

Main Options

The cksum command is very simple and takes file paths as arguments. Most Linux systems use the CRC32 algorithm by default, and no separate algorithm selection option is provided.

Basic Arguments

Information/Help

Generated command:

Try combining the commands.

Description:

`cksum` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Calculate Checksum for a Single File

cksum myfile.txt

Outputs the CRC checksum and byte count for the specified file.

Calculate Checksums for Multiple Files

cksum file1.txt file2.txt

Calculates and outputs the checksum for each of multiple files.

Calculate Checksum from Standard Input

echo "Hello Linux" | cksum

Calculates the checksum of data passed through a pipe (|).

Save Checksum to a File

cksum myfile.txt > myfile.cksum

Redirects the calculated checksum results to a file for saving.

Verify Integrity by Comparing with Saved Checksum

cksum myfile.txt | diff - myfile.cksum

Compares the checksum of the current file with a previously saved checksum file to check for file modifications.

Tips & Notes

cksum is useful for file integrity verification, but for security purposes, it is recommended to use stronger hashing algorithms.

Comparison of cksum and Other Hashing Tools

  • cksum (CRC32): Primarily used to detect accidental errors (corruption) that may occur during data transmission. Not suitable for cryptographic security.
  • md5sum, sha1sum, sha256sum: More robust for detecting intentional tampering of files and widely used for cryptographic security purposes. They have much higher collision resistance than cksum.

Detecting File Content Changes

The cksum value changes if even a single byte of the file's content is modified, allowing for quick detection of whether the file has been altered. This is useful for verifying the integrity of backup files or checking for corruption in downloaded files.



Same category commands