cksum- Unix, Linux Command


Previous Page
Next Page  


cksum - it generates a checksum value for a file or stream of data


cksum [FILE]...
cksum [OPTION]


cksumThe cksum command calculates and writes to standard output a cyclic redundancy check (CRC) and byte count for each input file. The cksum tool calculates its sum using a method similar to the FCS (frame check sequence) used to verify that ethernet packets are transferred correctly. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the file's CRC checksum and byte count. The cksum command can be used to verify that files transferred by unreliable means arrived intact.The checksum of a file is a simple way to check if its data has become corrupted when being transferred from one place to another. If the checksum value of the file is the same before and after being transferred, it is unlikely that any data corruption has accidentally occurred — from signal noise However, the CRC checksum calculated by the cksum command is not cryptographically secure: While it guards against accidental corruption (it is unlikely that the corrupted data will have the same checksum as the intended data), it is not difficult for an attacker to deliberately corrupt the file in a specific way that its checksum is unchanged. Unix-like systems typically include other commands for cryptographically secure checksums, such as sha1sum. The cksum command uses a different algorithm to calculate the 32-bit checksum CRC than the sum command. The cksum command uses a CRC algorithm based on the Ethernet standard frame check.


Tag Description
FILE The name of the file you want to check.
--help Display a help message, and exit.
--version Display version information, and exit.



To generate the checksum and bytecount of file.txt and output the values along with the filename:

$ cksum file.txt

nubo@nubo:~$ cksum file1.txt

52532972 15 file1.txt

Here, 52532972 is the checksum, and 15 is the amount of data, in bytes.


To generate checksums and bytecounts for two files  named file1.txt xyz:

$ cksum file1.txt xyz

52532972 15 file1.txt
3393634509 46 xyz


Running cksum with no options will allow you to type anything you like, pressing enter for new lines. When you are finished entering text, you can press CTRL-D to signal the end of standard input, and cksum will output the checksum and bytecount of the text that you entered.




1479881546 3


Previous Page
Next Page