|
|
|||
SEARCH FOR FILES WITH THE FIND COMMAND Trying to locate a missing file can be a time-consuming task. To track down elusive files, use the find utility, which is standard on every Linux distribution. Here's the general syntax of the find command: find [path] [expression] Find is a very small, comprehensive tool that allows for a wide variety of options and expressions to help search for files, such as searches based on the file name, last access time, last modification time, size, and ownership. For example, if you're looking for the file ulimit.h, use the following command: find / -name ulimit.h By default, find prints errors to the console, so you may accidentally scroll past the location of the file you're seeking amongst many "permission denied" messages. To resolve this, you can redirect all errors to /dev/null so you don't see them. Here's how: find / -name ulimit.h 2>/dev/null It's also possible to conduct more specific searches. To find files owned by the user "joe" that were modified in the last two days, use this command: find / -mtime -2 -user joe 2>/dev/null |
||||