Usually programs are installed in a couple of directories under one top directory, called a prefix. Which top directory to use depends on who is installing, for what purpose and who will manage the software.
The prefix /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.
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.
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 "~/
" or $HOME/
. I used that a lot when I was a student. :-)
Usually software does 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 log 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 var/
directory.
When the software is updated these directories need to have write privileges. Usually one does not need to do anything, but if needed 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 /dev
, /tmp
, /proc
and /srv
(for server data directories, but they are usually under /var/lib
or /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).
Different programs have different installation methods. --prefix
is useful for programs using configure
. Best way to know is probably to read the README.txt
file or something like that, which is probably provided with in the tar archive.
The tar archive can be extracted in any place, like your home directory. After the installation steps are done, you can remove the extracted tar archive if you are short of storage. But it's better to keep the directory as you can often use it for uninstallation.
Programs installed with apt-get
or aptitude
are always installed in the proper place for the distribution. You can't change that place.
make install
, which probably are under/usr/local
, which is the proper, traditional way to install your programs compiled from source. So it doesn't get in the way for the distribution and other software.There are there for a reason, like Linux isn't MS Windows, and you will probably be unhappy if you treat Linus distributions like they was MS Windows.
MS Windows is a single user OS, Linux is not. That is why there are different directories for binaries (programs). If you want to change that, you better make your own distribution.
– Anders Jan 26 '22 at 18:25