Using FIND command in Linux/Unix

This tutorial is dedicated to the ‘find’ command used in Linux/Unix operating systems.
‘Find’ is really powerful and commonly used command which helps in troubleshooting, finding stuff and as a part of server scripts.

The very common usage, just to find a file name or folder on your server is:

This will find all files or folders on a particular server with STRING included in the name located into the current folder and all the subfolder.

The next one will find string in files into the current folder and all the rest subfolders.


just for your information another way to find string in files :

Why I am giving you two or more commands?
Take in mind that the find command may be different on a different Linux and Unix based operating systems, and the syntax may differ.

Let’s see if we want to find all files bigger than 5MB:

Or find files bigger than 10MB using different find syntax :

To find user files you may search by ‘User ID’ into the systems (this may take time!)

To find all files modified in the last 5 minutes‘¦

… and if you want them all deleted:

Let’s find directories with certain permissions:

Here is how to find files with same permissions


Find files without associated user:

Find files modified and created last two days:

The next command will show you a list of SUID/SGID of programs in your system.

The next ‘find’ string will show you how many directories, files and links has a particular folder.

Note that if you remove the “-follow” ‘find’ parameter it wont search/ trace symlinks (Symbolic links).

With the following command you can find and replace in all files using ‘sed’, from the current folder recursively for a string (in my example ‘mamma mia!’) and will replace it with another which will be ‘daddy dog’.
(For the special characters you have to use so-called ‘escape’ character )

As it is too complicated you can find and replace with FIND and SED

It is very, very useful, but be careful how you are using it. It is a must to have backup, before messing all around!

With the next string one you can do a change on every ‘.php’ file in this case we are going to change the permissions of all files to 644 found inside the current and all of the subfolders.

Hope you liked the ‘find’ command examples. I am using them very often and even that I am referring to this tutorial for fresh ideas.

Think twice cut ones!


Filed Under: File system management

Anthony Gee About the Author: Anthony G. is an IT specialist with more than 9 years of solid working experience in the Web Hosting industry. Currently works as server support administrator, involved in consultative discussions about Web Hosting and server administration. One of the first writers in the website, now writing for Free Tutorials community - he is publishing tutorials and articles for the wide public, as well as specific technical solutions.

Comments (2)

  1. Gabby says:

    find / -name ‘*’ -user username -print

    This one searches for all files and folders owned by user ‘username’

    I was looking for this one, so I am just adding it as I use this page very often.

    Admins I hope you will find is useful also and leave it here.

  2. Great tooltip! Very helpful and time saving for me! Thank you Gabby!

Leave a Reply to Ivory Morhuld