Find Directory In Linux


Linux provides different ways to find directories. Here we will look how to find directories in recursive way.


Find command is popular command to used a lot of different purposes like find file and directory, take backup, copy files. Actually find do not have these abilities it just runs commands over search results like copy and backup.

Find have syntax like below

We will search for directory bin in the root file system.

Get Detailed Information

We can get detailed information about found directories by using -ls parameter for the find command.

Here results will list size of the directory permission of the directory, owner , last change date etc.

Only List Directories

Upto now we have search for all files and directories. We can search for only directories by providing type parameter with directory specifier.


Locate command is non interactive alternative to find command. Also locate have restricted capabilities. Advantage of the locate is that it is fast because locate use database to search. Manually a database for file and directories is created. Manually this database is updated. Search is done directly in this database. Database is located at /var/lib/mlocate/mlocate.db

We will update our database to search with locate. To update database we need root privileges.

We will search for files and directories ends with /bin . In this example we will use regex option of the locate to specify end of line.

LEARN MORE  C - File Operations, Open, Write and Close Files

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)