How to generate and verify the file checksums on Linux

This KB post is all about the file checksum, how to generate and verify the file checksums on Linux, and how accurate it is.

What is a file checksum?

A checksum is a sequence or a string of numbers and letters used to check data for detecting errors. A file checksum is like the digital fingerprint of a file. 

Mainly, the purpose of file checksums is to ensure that the data and software you download haven't been corrupted. In technical terms, a file checksum ensures you that during downloading the software from the web, the files were not modified in transit or storage. 

For instance, If the checksum of the software vendor and the download installation files matches that means there are no errors or modifications made. But, If the file checksums don�t match up, the download might have been corrupted or compromised by hackers.

How to generate file checksum on Linux?

Generally, each checksum is generated by a file checksum algorithm. In simple terms, it takes a file as input and gives the checksum value of that particular file as an output. There are several algorithms for generating checksums, the popular ones are: 

?        Secure Hash Algorithms and variants (SHA-1, SHA-2 etc.)

?        MD5 algorithm 


To generate a file checksum and store its value in a file, follow these steps: 

Step 1: First of all, log in to your account using SSH.

Step 2: After that go to the command prompt, and type one of the following commands. By replacing the filename with the name of the file for which you want to generate a checksum: 

?        This command is used to generate an MD5 checksum: 

md5sum filename > md5sums.txt 

?        To generate an SHA checksum, mention the command name for the hashing algorithm you want to use. For example, to generate an SHA-256 checksum, use the sha256sum command. To generate it, you would type the following command: 

sha512sum filename > sha512sums.txt 

Now, the md5sums.txt or sha512sums.txt, whatever you use, contains a file listing and associated file checksums. 

You can also generate multiple checksums in one go. For example, if you want to generate MD5 file checksums for the entire list of .zip files available in the current directory. Then, you need to type the following command: 

md5sum *.zip > md5sums.txt 

Similarly, to generate MD5 checksums for all of the files present in the current directory and beneath all these directories, type the following command: 

find . -type f -exec md5sum {} > md5sums.txt \; 

In case, if you find to generate SHA checksums instead of MD5, in the command, replace md5sum with the appropriate SHA command.

How to verify file checksums on Linux?

For verifying the MD5 and SHA file checksums on Linux include command-line programs. 


To verify the file checksums, follow these steps: 


Step 1: First & foremost, Log in to your account using SSH.

Step 2: To type the command based on the MD5 or SHA algorithms go to the command prompt and type one of the following commands used to generate the file checksums. 

These examples use the filenames md5sums.txt and sha512sums.txt. If you stored the checksums in any other file, then use that filename. 

?       To verify checksum through MD5 algorithm, type: 

md5sum -c md5sums.txt 

?      To verify SHA checksums, type the command name for the hashing algorithm you want to use. For example, to verify an SHA-256 checksum, use the sha256sum command. To verify it, you would type the following command: 

sha512sum -c sha512sums.txt 

Once it's done, you will get OK with each matching checksum, while got a message FAILED with each mismatched checksum. 

If you are doing a file checksum on a lot of files, mismatched results can get lost amongst all of the scrolling results. But if you want to see the mismatched results. You can display it by using the �quiet option. For example: 

sha512sum --quiet -c sha512sums.txt 

Other operating systems 


Apart from Linux, you can also generate and verify file checksums on other operating systems too. 


?        For a Microsoft Windows, you need to download and install one of the many programs available for generating and verifying checksums.

?        For an Apple macOS, you need to use the md5 and shasum programs at the command line. 

How accurately does this work?

If you want to know how accurate these file checksums work to detect the corrupted files, then check this out. 

For instance, If you delete or make any minor change even a change of a single character in one of the text files inside the iso image. Then the checksum algorithm will generate a completely different value for that change. As a result, that will not match with the checksum provided on the download page.

Do you checksum?

An integrity check of a file is a crucial part of ensuring a secure system. Specifically, when downloading the files from the internet. Through this write-up, we discussed how to generate a file checksum and how we use it for a file integrity check.

Was this guide helpful? In case of any queries or suggestions, please let us know! And if you need a similar guide for something else or any support from our support team, reach out to us, we�re here to help.

Was this answer helpful? #9 #9
 

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Submit your Query

  • I'm not a robot

Browse by ServicesBrowse by Services

Resource Library

What is Cloud Computing

Understand the term cloud computing, the ongoing trend, its playing field, future growth and how industry...

Myths about Cloud Computing

Cloud computing, in the recent years, has become a subject of significant discussion among the industry experts.

Download Now

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Submit Query

Please fill in the form below and we will contact you within 24 hours.