Usually program are installed in a couple of directories under one top directory, called a prefix. Which top directory to use depends on who are installing, for witch purpose and who will manage the software.
/usr is used software packed by your distribution. You should not install any other software there, because it will confuse the distribution when installing and upgrading software packed by the distribution. So please do not install your own compiled software there. That is not a good idea, unless you really know what you do. And unless you are an Debian or Ubunut developer, you usually don't. I wouldn't do that anyways.
For commercial software, the prefix
/opt is used. It's reserved for them to interfere least with distributions and the local system administrator.
For software the system administrator installs for all users, the prefix
/usr/local is used. There It's out of the way from both commercial or distribution installation and will not interfere with them. So as a system administrator you use that (if you have root privileges you are a system administrator).
If you are an ordinary user installing software for yourself, you could use your home directory as prefix, by using the
--prefix option to
configure with prefix directory "
$HOME/. I used that a lot when I was a student. :-)
Usually software do the right thing when you execute
configure with the option
--prefix with the right value and then
make; make install.
Under any of these prefixes, you usually find these directories in a standard installation.
bin - the executable programs, binaries.
sbin - system binaries, which usually should not be executed by ordinary users.
man - manual pages for programs, libraries and config files etc.
etc - config files with default values for the software.
lib - program libraries and data files that are dependent on architecture (like the CPU) in your computer.
share - data files that are not different on different architectures, and can be shared between different computers.
var - directories with data that changes during program execution. Like logging files etc.
Most of those directories can be used with write protected file systems to increase security. The only one that users need to write to is the
When the software is updated these directories obviously(?) need to have writing privileges. That can be done with a remount with write privileges during installation and then remounted with read only after installation. But this is advanced, and I only give it as an example of advanced package management.
There are also some directories directly under
/ (the root directory) which don't exists under any other prefix, like
/srv (for server data directories, but they are usually under
/var/www and directories like that, so you need to change configuration to use this directory. I do recommend that you do that when you are running a server. Only use
/var/ for testing out a standard installation).
- Linux isn't MS Windows. There are many places to place programs you install. It depends who install and for whom. Read it in my post. Notice. RedHat uses
/usr as Debian/Ubuntu uses
/usr/local. Learn your distribution.
- Different programs have different installation methods.
--prefix are usefull for programs using
configure. Best way to know is probably to read the
README.txt file or something like that, which you probably are provided with in the tar archive.
The tar archive can be extracted in any place, like your home directory. After the installation step are done, you could remove the extracted tar archive, if you are short of storage. But don't do that to early, unless you have tested your installation properly.
- Programs installed with
aptitude are always installed in the proper place for the distribution. You can't change that place.