Finding files and file paths within your directory structure: There are many different ways to search within linux based command line. Some of the easier ways will be touched within this post. Keep in mind that you can always use the manual to tell you all the functions of a particular command. Type ‘man’ followed by a space and the command you wish to learn more about.
Lets get started with the different commands that will help you to find your files or even text within those files.
Locate: A simple command that all you really need to do is type in “locate” and the file you want to locate and it will give you the path to that file. Like this:
Find: Another method is to use the “find” command to locate a file, this can be a little more helpful in certain situations.
GREP: which is another great tool for finding pretty much anything in or outside of a file. GREP is a very strong tool and you will need to be very careful about how you use it or you will be overwhelmed with excessive results. You can use it to find strings within files on your sever. There are many tutorials out thee on this command so I will only be doing a quick basic on some of the key features of this one.
Here is a short example, note that the ‘ ‘ marks are needed within this command:
grep 'strong to search for' filetosearch.in
** See notes for details on above code
*: as typical with my postings replace text within ‘ ‘ marks with what you feel is necessary or described in my posts.
**: In the case of this code you will need to leave the ‘ ‘ in place as they are the markers for the string, whatever you are searching for will be contained within the ‘ ‘ marks