Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    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

    RahulBy RahulDecember 7, 20141 Min ReadUpdated:August 22, 2018

    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.

    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
    Previous ArticleHow to Create VirtualHost in Tomcat 10/9/8
    Next Article The Enterprise Cloud is more Than Just Storage

    Related Posts

    How to Search Recently Modified Files in Linux

    2 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    Tee Command in Linux with Examples

    4 Mins Read

    How to Scan Open Ports with Nmap

    5 Mins Read

    Handling filenames with spaces in Linux

    3 Mins Read

    How To Compare Two Files in Linux

    Updated:August 23, 20215 Mins Read

    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

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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