How to Locate stuffs in Linux – Part 1

By | August 19, 2016

The ability to know where your stuffs (that is files) are stored in your hard drive is necessity for any PC user. This is because majority of everyday interaction with the computer system exclusively involves manipulating files – and by extension directories. Such manipulation include copying, moving edit and the likes. And in the Linux world everything is seen as a file, so the ability to easily get to this files is something that could save time and energy on a very good day. Though most Linux distro come the default NAUTILUS file explorer that could be used to search for files, there is limit to its reach there are some files that can’t be searched for with it (like configuration or system files). The best bet is to use the command line. So in this post and the ones to follow we would be dealing with how we could do this using the command line.

First, we would be using the Linux command find (ironic isn’t it).

The find command:

This command is used to search for files in the given directory, hierarchically starting from the parent directory and moving to sub-directories.

The find command is used to locate a file in a particular directory and in all its subdirectories. It is the most commonly used command for locating files and has various options for advance search.


find [path] [regular_expression]

The -name option is used to specify the name of files that are to be searched.


Consider the following command;

find /home/alexander -name *.txt





Here, /home/Documents is the name of the directory in which the search is to begin (when no path is specified the whole hard drive is searched). The name “*.pdf” specifies that files that ends with a .pdf extension (all PDF files) are to be searched. The * is a wildcard and represent every instance of files having that extension. But you can use filename or a part of file name to customize the output.

The find command without the -name option displays the path names of all the files under the specified directory and its subdirectories. And also the -name option makes a case sensitive search, but using the -iname option searches without any regard for the case.

find /home/alexander

The -type option: the -type option is used to locate a file of a specific type. In the command given below;

find /home/alexander -type f

The f with -type will search for all the ordinary files. To search for directories, the command is;

find /home/alexander -type d


READ  How safe is a Personal Packaging Archive(PPA)?


Happy Linux’NG




Chief Editor/Founder at FossNaija
A Linux enthusiast with a focus on enriching the Nigeria Linux experience and keeping a keen eye on Ubuntu and other Foss related developments.

Tell us what you think