Command | Syntax | Description | Example |
---|---|---|---|
grep | grep [options] pattern file(s) | Search for a pattern in a file or files | grep "error" file1 – Search for the string “error” in file1 |
find | find [path] [expression] | Search for files and directories based on various criteria | find / -name "error.log" – Search for a file named “error.log” starting from the root directory / |
locate | locate [pattern] | Search for files based on their names using a database of all file names on the system | locate error.log – Search for a file named “error.log” |
which | which [command] | Show the full path of a command | which ls – Show the full path of the ls command |
whereis | whereis [command] | Show the location of a command’s executable file, source code, and manual page | whereis ls – Show the location of the ls command’s executable file, source code, and manual page |
command | grep pattern | command | grep pattern | Search pattern in the output of a command | more abc.txt | grep exception |