Robert Elder Software Inc.
  • Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'cksum' Command In Linux

2024-05-16 - By Robert Elder

     I use the 'cksum' command to compute a cyclic redundancy check checksum of a file or stream:

cat example.txt
Hello World!
cksum example.txt
2116921653 13 example.txt

Purpose Of 'cksum' Command

     The purpose of this command is for detecting data corruption that can occur during network communication, or due to failing storage media:

Ethernet Plug
info cksum
   ‘cksum’ is typically used to ensure that files transferred by
unreliable means (e.g., netnews) have not been corrupted, by comparing
the ‘cksum’ output for the received files with the ‘cksum’ output for
the original files (typically given in the distribution).

Reading The Output Of 'cksum' Command

     If I run the 'cksum' command an a file like this:

cksum data.dat

     I'll see the CRC checksum value (in this case 3779003720), followed by the number of bytes in the file (in this case 26):

3779003720 26 data.dat

How The 'cksum' Value Is Calculated

     According to the POSIX specification, the CRC checksum value is calculated using the following generator polynomial:

G(x)=x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1

     This polynomial is based on similar one used by an error checking algorithm described in a 1996 telecommunications standard for Ethernet communication.

     The checksum calculated by the 'cksum' command is not cryptographically secure, and should only be used for detecting accidental, rather than deliberate data corruption.

     And that's why the 'cksum' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Intro To 'stty' Command In Linux
Published 2023-10-04
Terminal Block Mining Simulation Game
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'nproc' Command In Linux
Intro To 'nproc' Command In Linux
Published 2023-07-15
Intro To 'comm' Command In Linux
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Intro To 'chroot' Command In Linux
Published 2023-06-23
Join My Mailing List
Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
SocialSocialSocialSocialSocialSocialSocial
Privacy Policy      Store Policies      Terms of Use