
Let's see how that looks with an example. The second value is the amount of data in bytes for the given file.Įven a slight modification changes the hash value.We can calculate its checksum like this: cksum calculator.py Let's suppose we have a file named calculator.py.
#Checksum command how to#
The basic syntax is as follows: cksum How to Use cksum The cksum command takes the filename as an argument and generates its hash value. To learn more about the CRC algorithm, refer to this page.

How to Find the Checksum in Linux using cksumĬksum is a command found in *nix-like operating systems that generates a checksum value for a file or stream of data.Īccording to the man page of cksum, the command prints CRC (cyclic redundancy check) checksum and byte counts of each FILE. Next we will see how we can calculate the hash in Linux. Some commonly used cryptographic hash functions include MD5 and SHA-1. If the hash value is same, it implies that your copy of the file is genuine and error free. In networking, you can use checksum to compare the hash value at sender and receiver ends. It's applied to blocks of the data in the file. To ensure that the data remains consistent, we can use checksum.Ĭhecksum is the result of an algorithm called a cryptographic hash function. Sometimes the data gets corrupted during transmission or storage. The method is called 'checksum' and the corresponding command for that in Linux is cksum. The methods mentioned above usually get the task done, but there is an advanced method to check file integrity using a hash. rw-r-r- 1 zaira zaira 263 Jul 19 13:22 calculator.py File size is 263 bytes The 5th column shows the size of the file in bytes. We can view the file size using long listing( ls -l). If we know the previous size of the file, we can compare it with the current file size to see if was changed. rw-r-r- 1 zaira zaira 263 Jul 19 13:22 calculator.py File modification time is Jul 19 13:22 How to Check if a File Was Modified by Checking File Size In the output below, we can see that the file was modified on Jul 19 13:22.

We can view the last modified time of a file using long listing( ls -l). When a file is edited, its timestamp changes to match the modification time. In case you need to check if file was modified, you can follow these two approaches: How to Check if a File Was Modified by Checking Modification Time Linux has a powerful command line which allows you to explore multiple aspects of files and filesystems. When you are working with files on the command line, you might need to check their modification time and content integrity.
