Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Commands»How to Generate md5 checksum for all Files in a Directory

    How to Generate md5 checksum for all Files in a Directory

    By RahulAugust 22, 20181 Min Read

    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
    

    md5 md5sum
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    free Command in Linux (Check Memory Uses)

    A Practical Guide to Extracting Compressed Files in Linux

    TR Command in Linux: A Guide with Practical Examples

    TR Command in Linux: A Guide with Practical Examples

    View 2 Comments

    2 Comments

    1. Matthew on August 21, 2018 7:21 pm

      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.

      Reply
    2. anon on November 2, 2015 1:13 pm

      md5sum -c ~/usermd5.list | grep -v OK

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting Up Angular on Ubuntu: Step-by-Step Guide
    • Converting UTC Date and Time to Local Time in Linux
    • Git Restore: Functionality and Practical Examples
    • Git Switch: Functionality and Practical Examples
    • Git Switch vs. Checkout: A Detailed Comparison with Examples
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.