Wikipedia

cksum

cksum
Operating systemUnix, Unix-like
PlatformCross-platform
TypeCommand

cksum is a command in Unix and Unix-like operating systems that generates a checksum value for a file or stream of data. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the file's CRC-32 checksum and byte count.

The cksum command can be used to verify that files transferred by unreliable means arrived intact.[1] 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 sha256sum.

Interoperability

The standard cksum command, as found on most Unix-like operating systems (including GNU/Linux, *BSD, macOS, and Solaris) uses a CRC algorithm based on the ethernet standard frame check and is therefore interoperable between implementations. This is in contrast to the sum command, which is not as interoperable and not compatible with the CRC-32 calculation. On Tru64 operating systems, the cksum command returns a different CRC value, unless the environment variable CMD_ENV is set to xpg4.

Algorithm

cksum uses the generator polynomial 0x04C11DB7 and appends to the message its length in little endian representation. That length has null bytes trimmed on the right end.[2]

Syntax

cksum [FILE]... cksum [OPTION] 

Usage example

$ cksum test.txt 4038471504 75 test.txt 

where 4038471504 represents the checksum value and 75 represents the file size of test.txt.

See also

References

  1. ^ "cksum: Print CRC checksum and byte counts". Retrieved 2015-07-05.
  2. ^ "cksum". pubs.opengroup.org.

External links

This article is copied from an article on Wikipedia® - the free encyclopedia created and edited by its online user community. The text was not checked or edited by anyone on our staff. Although the vast majority of Wikipedia® encyclopedia articles provide accurate and timely information, please do not assume the accuracy of any particular article. This article is distributed under the terms of GNU Free Documentation License.

Copyright © 2003-2025 Farlex, Inc Disclaimer
All content on this website, including dictionary, thesaurus, literature, geography, and other reference data is for informational purposes only. This information should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional.