Generate md5 checksum
find /var/www -type f -exec md5sum {} \; > /tmp/www-md5.list
Above command will generate md5 checksum for all files in current directory and its sub-directory and store it in /tmp/www-md5.list file.
Advertisement
Generate md5
If we want to generate md5sum of all files in our home directory and its sub-directory. Use the following command.
find /var/www -type f -exec md5sum {} \; > /tmp/www-md5.list
If we want to generate md5sum for specific files for example all php and JavaScript files under public_html directory use following command.
find ~/public_html/ -name "*.php" -exec md5sum {} \; > ~/usermd5.list find ~/public_html/ -name "*.js" -exec md5sum {} \; >> ~/usermd5.list
Verify md5
Now verify all files using generated md5sum file using the following command. This command will show output as OK or FAILED.
md5sum -c /tmp/www-md5.list
2 Comments
I believe you need to put the quotes around the semicolon, not the braces.
$ find ~/ -exec md5sum {} “;” > ~/usermd5.list
The reason is that -exec needs to see the semicolon as an argument passed to the find command. If you do quote the semicolon, the shell interprets the semicolon as a command separator, rather than a command argument.
md5sum -c ~/usermd5.list | grep -v OK