All too often you need to find a specific file in Ubuntu. When I need to find files in Ubuntu, the “search for Files” tool is usually inadequate for me. So I typically open up the Terminal and use the find command, which can be found to be a bit tricky to use, but powerful.
I typically need to search the entire hard drive for the file I am trying to find. So once in the Terminal, just issue the following command:
sudo find / -name’ xorg.conf’
In this case, we are looking for the file “xorg.conf” and the -name option tells the find command that we are looking for a file name, and the / tells the find command that we want to start at the root.
You can also use wild cards as well. For example. if we want to find all of the .conffiles on our hard drive, just issue the following command:
sudo find / -name ‘*.conf’
Typically issuing this sort of a find command there will be a lot of files scrolling off the screen. So just pipe the find command to the more command like this:
sudo find / -name ‘*.conf’ | more
Then just hit the space bar to view the next screen. Additionally, it is good practice to use single quotes when specifying the files you want to find otherwise the results may become unpredictable.
Here are some other examples for using the find command:
sudo find /home -user mike
Find all files owned by the user mike in the /home directory
sudo find /etc -name ‘*.cnf’
Find all files in the directory /etc ending with “.cnf”
sudo find /var/spool -mtime +60
Find all files in the directory /var/spool that was modified more than 60 days ago.
These are just a few basic examples on how to use the find command. For a complete list of all of the options of the find command, look at the man pages.
This article was originally posted on www.mikestechblog.com Any reproduction on any other site is prohibited and a violation of copyright laws.