How to Find Files, Folders and Directories In Linux From Command Line?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/find-files-folders-directories-linux-command-line/
PINTEREST
PINTEREST
INSTAGRAM

Linux provides different ways to find and locate files and folders. We can use GUI tools like GNOME and KDE file managers or other 3’rd party applications designed for finding files. In this tutorial we will look how to find files, folders and directories from command line.

Tools

As stated previously there are a lot of tools those can be used to find files and folders. We will look in detail all of them. Here list of these tools.

  • find
  • locate
  • grep
  • which
  • whereis

Find Command

findcommand is very featureful command used with a lot of different options. More details about find command can be found from following tutorial.

Linux Find Command With Examples

Find Only Files

We can search only files by providing file type as -type f. We will search files those named conf in this example.

Find Only Folders

We may need only find folder. We will specify the type like below as directory.

Find Only Folders

Find Only Folders

Locate Command

locate command can be used as a offline database of all files and folders. locate will search a database which is created with updatedb command. More detailed information can be get from following tutorial.

locate Command Tutorial With Examples For Linux To Find Files

As locate database only holds file and folder names we can not search in detail. But this database provides us very fast search option then find command because it works offline.

LEARN MORE  Linux wc Command Word and Line Count Tutorial With Examples

Update Database

As stated previously locate uses database to search file and folders. Updating this database is important before a search. Update will take very little time.

Search For File or Folders

We will use locate command and the file and folder name to search.

Search For File or Folders

Search For File or Folders

Grep Command

grep command mainly filters given text and files contents but we cna use it for to find files and folders. For more detail

Introduction to Linux Grep Command With Examples

We can use ls command recursively and grep the files and folder we want to find.

In this example we will search files and folders those names contains backup .

Grep Command

Grep Command

Which Command

whichcommand is not a actual file and folder search. which command simply search current environment executable files. This is generally useful if we are looking a command which is not included in PATH variable and can not used automatically.

Which Command

Which Command

Whereis Command

whereis command is used to list given search term related binary, source or man page files.In this example we will search for ls binary and related man page files.

Whereis Command

Whereis Command

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/find-files-folders-directories-linux-command-line/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)