cksum - Linux


The cksum command in Linux is used for computing and verifying checksums and byte counts of a file. Its primary function is to ensure that files have been transferred or stored without corruption. cksum is commonly utilized in network data transfers, data integrity checks, and in automated scripts where file integrity verification is mandatory.


The basic syntax of the cksum command is:

cksum [OPTION]... [FILE]...

If no FILE is specified, or when FILE is -, it reads the standard input.


  • -, --: Treat the following arguments as file names even if they begin with a dash.
  • --help: Display a help message and exit.
  • --version: Output version information and exit.

These options allow the user to feed data directly into cksum from the standard input, get help, or check the version of the cksum utility being used.


  1. Basic Checksum Calculation:
    Calculate the checksum and byte count of a file:

    cksum myfile.txt

    This will output three values: the checksum, the size of the file in bytes, and the file name.

  2. Calculating Checksums for Multiple Files:
    To compute the checksums for multiple files:

    cksum file1.txt file2.txt file3.txt
  3. Reading from Standard Input:
    You can also pipe the output of another command into cksum:

    echo "Hello, World!" | cksum

    This outputs the checksum and byte count for the given string.

Common Issues

  • File Accessibility: Make sure that the files are readable. Lack of permissions will result in an error.
  • Non-existent Files: Specifying a file that does not exist will also result in an error message.

To avoid these issues, ensure you have the correct file paths and sufficient permissions.


cksum can be effectively combined with other commands for more complex tasks:

  • Verifying Backup Integrity:
    Generate checksums before and after transferring them:

    cksum original_file.txt > original_file.cksum
    # After transfer
    cksum transferred_file.txt > transferred_file.cksum
    diff original_file.cksum transferred_file.cksum

    This script will generate checksum files and then compare them using diff.

  • sum: Another utility for checksum calculation, but uses different algorithms.
  • md5sum, sha1sum, sha256sum: These commands compute MD5, SHA1, and SHA256 hashes respectively, offering more robust methods of checksum terms of security and collision resistance.

For more detailed information, the man pages for these commands (man cksum, man md5sum) or online documentation at GNU Coreutils can provide further insights.