Finding Things
The following commands are used to find files. “ls” is good for finding files if you already know approximately where they are, but sometimes you need more powerful tools such as these:
Linux Command | Description |
which | Shows the full path of shell commands found in your path. For example, if you want to know exactly where the “grep” command is located on the filesystem, you can type “which grep”. The output should be something like:
/bin/grep |
whereis | Locates the program, source code, and manual page for a command (if all information is available). For example, to find out where “ls” and its man page are, type: “whereis ls” The output will look something like:
ls: /bin/ls /usr/share/man/man1/ls.1.gz |
locate | A quick way to search for files anywhere on the filesystem. For example, you can find all files and directories that contain the name “mozilla” by typing:
locate mozilla |
find | A very powerful command, but sometimes tricky to use. It can be used to search for files matching certain patterns, as well as many other types of searches. A simple example is:
find . -name \*mp3 This example starts searching in the current directory “.” and all subdirectories, looking for files with “mp3” at the end of their names. |