Cksum
Template:Short description
Template:Lowercase title
{{#invoke:Infobox|infobox}}Template:Template other {{#invoke:Check for unknown parameters|check|unknown=Template:Main other|preview=Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y| AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo class | logo size | logo title | logo upright | logo_alt | logo_caption | logo_class | logo_size | logo_title | logo_upright | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | qid | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot class | screenshot size | screenshot title | screenshot upright | screenshot_alt | screenshot_class | screenshot_size | screenshot_upright | service_name | size | standard | title | ver layout | website }}Template:Main other
cksum is a shell command for generating a checksum for a file or stream of data. The command reports the 32-bit cyclic redundancy check (CRC) checksum and byte count for each file specified in the command-line arguments or for standard input if no arguments provided.<ref name=":0" /> The CRC value is different from the CRC-32 used with a ZIP file, PNG or zlib.<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref>
The command can be used to verify that files transferred (possibly via unreliable means) arrived intact.<ref name=":0">{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> However, the checksum calculated 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.
The command is available on Unix and Unix-like system and via UnxUtils.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> The GNU Coreutils implementation provides additional checksum algorithms via <syntaxhighlight lang="text" class="" style="" inline="1">-a</syntaxhighlight> option, as an extension beyond POSIX.<ref name=":0" />
The standard command, as found on most Unix and Unix-like operating systems (including Linux, *BSD,<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> macOS, and Solaris<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref>) uses a CRC algorithm based on the ethernet standard frame check<ref name=":1" /> 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.Template:Citation needed
The command 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.<ref name=":1">{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>
Examples
The following calculates the checksum for file test.txt. The checksum is 4038471504 and the file size is 75 bytes.
<syntaxhighlight lang="console"> $ cksum test.txt 4038471504 75 test.txt </syntaxhighlight>
See also
- Template:Annotated link
- Template:Annotated link
- Template:Annotated link
- Template:Annotated link
- Template:Annotated link
References
External links
- Template:Man
- cksum – GNU Core Utilities
- Template:Man
- Template:Man