} md5sum_current_directory will save the md5 sums in the file called md5sum_current_directory. Check this..." > md5sum_current_directory will save the md5 sums in the file called md5sum_current_directory. Check this article for more details" >

How to Generate md5 checksum for all Files in a Directory

Created:

Introduction

In this small tutorial we are going to explain how to calculate the md5 sum of all the files in a directory. You can also use sha256sum instead md5sum, you only need to replace md5sum by sha256sum.

How to Generate md5 checksum for all Files in a Directory

We are going to use exec parameter of the find command to execute md5sum, then we will store the result of the command to a file called md5sum_current_directory:

find . -exec md5sum "{}" ; > md5sum_current_directory

You can change the path in the find parameter to calculate the md5sum of all the files in another directory, example:

find /var/www -exec md5sum "{}" ; > ~/www_md5sums

Above command will calculte md5sum of all www files. You can also play with the -name parameter of the find command to filter files by extension.

How to Verify MD5 sums of all files in directory

First to verify md5sum you need the file of the previous step, like the one called md5sum_current_directory.

This is how to use it:

md5sum -c md5sum_current_directory

You can always replace md5sum by sha256sum.