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.
The -name option is used to specify the name of files that are to be searched.
Consider the following command;
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.
The -type option: the -type option is used to locate a file of a specific type. In the command given below;
The f with -type will search for all the ordinary files. To search for directories, the command is;
Latest posts by ALEXANDER WAYNE OMOROKUNWA (see all)
- What is The Linux Swap Partition? - May 3, 2018
- 6 Commands you must know to be Productive on the terminal. - April 19, 2018
- Microsoft is Making love to Linux in the Windows store. - April 12, 2018