4 Answers
4

e.g. which vim shows the location of vim which'll be used, if you tried to run vim command on terminal. Also whereis command won't show the location of command if its in your home directory. For example. if your ~/bin directory has a command pqr whereis won't show the location of pqr. which pqr shows its location too.

If you have set the aliases for the commands, for example if your terminal understands the shortcut c for clear command for example, you can get the original command, by typing the command:

Other than on Windows, on Linux systems an application is (usually -- there are few exceptions) not tried to be installed into "one place" (no such thing like C:\Program Files\AppName holding almost all the applications files).

Instead there are dedicated places where to put executables (what you call from the command line or via your graphical interface's menu), another for libraries used by applications (so multiple applications can share the same library and automatically profit from its updates), configuration files, documentation, and so on.

As already pointed out, you can use the which command to tell you the executable used, and there is the whereis command. A third command coming in handy is locate, which would list up all files in the system having the specified string in their /path/to/filename, plus the powerful find command.

You can get more information about each of them reading their Man pages -- e.g. man find would tell you how to use the find command.

In general you shouldn't need to know the location of programs, because if you need to run them from the command-line then they'll be on your path anyway, and if you run them from within the GUI, or within another application, they'll be set up in there by their installation script.

But if you are curious, most executables will be placed into /usr/bin

(Or at least a symbolic link from there will exist to the executable.)

There are exceptions. There will be some system-related ones that are available from /bin instead, and some system-related ones only intended for superuser access (ie, for use with sudo) in /sbin.

The which command can be used to find out exactly where an application is (if you run it by typing its name on the command-line). You use it like which <command> where command is replaced with the command you'd type. For example:

which apt-get

Tells you: /usr/bin/apt-get. As I said above, most executables are placed in /usr/bin ;)

If you type the following

ls /usr/bin -l

Then it will show you all the files in /usr/bin. You'll then notice that some of them are actually symbolic links to elsewhere.

Now, /usr/bin will only contain the executable file. All of its support files will be in different locations (usually within /usr). For example, library files it requires will be in /usr/lib, and non-executable data files it needs will be in /usr/share. It may also store configuration or state information in /var/lib, or in users' home directories.