Tag Archives: checksum

Validate files in Linux using MD5 checksum

You can use MD5 checksum to validate the integrity of a file that may have been corrupted or tampered with. Possibly while downloading/uploading the file you will need to check the validity of the file.

Most of the download sites also provide a MD5 checksum along with the download which can be used for validation of download.

This method is also useful when you are transferring files across different hosts.

GENERATE THE MD5 CHECKSUM

# md5sum <file_name>

Ex:

# md5sum test.sh

OUTPUT:
# 7fca3f2f1689973efce688be46193aff test.sh

You can also specify multiple files

# md5sum <file_name_1> <file_name_2> ...

Redirecting output to a file:

# md5sum <file_name> >> md5.txt

VALIDATING THE MD5 CHECKSUM

Using output file (running from the same directory)

# md5sum -c md5.txt

OUTPUT:
# test.sh: OK