How To Find Directory In Linux? – POFTUT

How To Find Directory In Linux?

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

Find

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.

Syntax

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.

Get Detailed Information

Get Detailed Information

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

Only List Directories

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

Only List Directories

Only List Directories

Locate

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  Windows Dir Command Tutorial With Examples To List Files and File Information

Locate

Locate

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)