Posted on March 28, 2020
How to use the “Find” command in Linux
Today I will teach you how to use the
find command. The
find command is used to search and locate files in a given directory. I will show you how to use the command in its most basic form.
The syntax command is:
$ find <location> -name <searchpattern>
You will run into “Permission denied” if you don’t have the proper permissions to the folder. Otherwise it will look for the given search pattern and show you all the ones it could find.
In this example I will be looking for my passwd file
$ find "/" -type f -iname "passwd"
The find command will start its search at the root “/”, recursively – meaning it will look through its sub-directories.
-type -f means it will look for a file type and I am asking it to look for the passwd file in case-insensitive mode by adding the
Output: /sys/fs/selinux/class/passwd/perms/passwd /usr/share/licenses/passwd /usr/bin/passwd
find command is a very helpful tool that you should add to your arsenal. It will make looking for files and directories fast and easy.