How to Search for Files in Linux
Open terminal in Linux Type pwd and press enter to see what path you are in Type ls and press enter to see list of directories, or folders, that are on your computer ; , find ., find / -name 'mypage.htm' The above command would search the system for...
Step-by-Step Guide
-
Step 1: Open terminal in Linux Type pwd and press enter to see what path you are in Type ls and press enter to see list of directories
-name 'mypage.htm' The above command would search the system for any file with the name mypage.htm in the current directory and any subdirectory , You may get a lot of warnings such as:
To suppress those warnings, type find /
-name 'mypage.htm' 2>/dev/null The warnings will be suppressed and you will only get the list of files that you have permission to. ,
-name 'file*' The above command searches for any file beginning with 'file' in the current directory and any subdirectory.
For example, if searching for a file that starts with 'Hello' : , This would mean that it will not find files that have been created the same day or hour (depending on when the database updates). -
Step 2: or folders
-
Step 3: that are on your computer ;
-
Step 4: find .
-
Step 5: find / -name 'mypage.htm' The above command would search the system for any file named mypage.htm on the root and all subdirectories from the root
-
Step 6: which would include your harddrive and any other drives you have plugged in.
-
Step 7: find .
-
Step 8: locate Locate is a similar command to find / -name
-
Step 9: but instead of checking every folder on the system
-
Step 10: it searches a database that is usually updated regularly.
Detailed Guide
-name 'mypage.htm' The above command would search the system for any file with the name mypage.htm in the current directory and any subdirectory , You may get a lot of warnings such as:
To suppress those warnings, type find /
-name 'mypage.htm' 2>/dev/null The warnings will be suppressed and you will only get the list of files that you have permission to. ,
-name 'file*' The above command searches for any file beginning with 'file' in the current directory and any subdirectory.
For example, if searching for a file that starts with 'Hello' : , This would mean that it will not find files that have been created the same day or hour (depending on when the database updates).
About the Author
Cynthia Ramirez
Writer and educator with a focus on practical pet care knowledge.
Rate This Guide
How helpful was this guide? Click to rate: