I search for files often in my files system by either using the tree command and grep, or the find command, but recently I downloaded some content from a site, but forgot where I saved it, now I know that SHA256sum of it, but I do not know it's name, and I do not know any of its contents. So is there any way of searching through my system to find any files which match that particular hashsum? And if there is not an already built in easy way, can someone suggest a script which would allow me to complete this task?

OS Information:

Description:    Ubuntu 15.04
Release:    15.04

1 Answer 1


Use this:

find /home/user/ -type f | while IFS= read -r file; do
    [[ "$(sha256sum "$file" | cut -d' ' -f1)" == $saved ]] && echo "$file"
  • saved will contain the hashsum of the file you have

  • It will find all the files in /home/user/ (replace it with the location(s) you want) and subdirectories and will match their hashsums with saved

  • If matched, it will print the file name

Run the script using sudo in case if you want to search the places you don't have required permissions.

Note that this operation is quite cpu intensive as it will calculate the hashes of all the files and then try to match with the saved one. I am not aware of any standalone tool that can achive what you want, so this might be the way to go given the task and input in hand.

Also note that you can minimize the amount of files to be searched by applying relevant options to find e.g. if the file was accessed within last 24 hours use find /location -atime 0 -type f.

You must log in to answer this question.