Find a File in Bash


If you are searching for a file in a bash shell, you first have to update the DB by running the command:


After that, you can use the command locate to search for your file:

locate v-add-letsencrypt-domain

Output should be something like that:

root@s001:~# locate v-add-letsencrypt-domain 


Another option would be to use the command find:

find . -name '*.txt'

The command above searches the current directory for all *.txt files. If you want to exclude directories, add the parameter -type f:

find . -type f -name '*.txt'

If you want to search through all directories, you can use the commend below – but it may take some time, so better specify a directory:

find / -type f -name myfile.txt