Which Program?
- 0
- Add a Comment
Which Program?
If you’re not sure a program is installed on your Linux system, there are several ways to check. One is the find command that we talked about near the beginning of Penguin Shell. Another is the which command, a small searching program that takes a bit of a different tack on finding that lost application.
The which command lists the full pathname of a file that would be executed if a named command is run. which limits its search to the $PATH environment variable, meaning that it will only list programs that can be run by simply entering the program’s name in the console window. For example, if I enter bluefish in a console window, without the full path, the bluefish program will still execute. That’s because it’s in a directory listed in the $PATH variable. If I search for bluefish using the which command, [which bluefish] I’ll see that it’s located in the /usr/bin/ directory - a directory listed in the $PATH variable.
As always, the which command has a fistful of tweakable options to make it do only what you need or want it to do.
| Option | Action |
| a | print all matches, not just the first |
| i | read aliases from the standard input and write the matches to the standard output. |
| –skip-dot | skip all directories that start with a dot |
| –skip-tilde | skip all directories that start with a tilde |
| –show-dot | print ./cmdname instead of the full pathname if a matching command is found in a directory that starts with a dot |
| –show-tilde | indicate a user’s home directory by printing a tilde (~) |
Now you’ll never need to search long and hard again. Just ask your Linux system which.
