How to search for a file or directory on Linux CLI

This is a quick reference guide on how to find a file or directory on Linux Based Operating Systems.

To search by name – case sensitive.

root@VPS:~# find / -name sshd

To search by iname – not case sensitive.

root@VPS:~# find / -name SSHD
root@VPS:~# find / -iname SSHD

You will see that the -name command above does not return anything when searching for SSHD but the -iname does.

To search for a file or directory.

root@VPS:~# find / -type d -name sshd
root@VPS:~# find / -type f -name sshd

In the above example you are searching for either just files or directories containing sshd. The -type d option is to search by directory and the -type -f option is to search for files.

To search for a file or directory containing certain words or characters using a wildcard.

root@VPS:~# find / -type f -name sshd
root@VPS:~# find / -type f -name *sshd*

As with the previous example when searching with just “sshd” that will return results with the exact name of the file or directory. When adding * on either side of the search term this will return results any file containing the word “sshd”.

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to

Thank you for reading and please feel free to leave any feedback.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s