Sunday, October 27, 2019

While installing packages, which is the directory best?

If the application has a makefile, or for example for python apps if the application uses distutils (e.g., has a setup.py file), or a similar build/install system, you should install it into /usr/local/. This is often the default behavior.

From what I understand, /usr/local/ has a hierarchy that is similar to /usr/. However, directories like /usr/bin/ and /usr/lib/ are usually reserved for packages install via apt. So a program expecting to get "installed" into /usr/ should work fine in /usr/local/.

If you just need to extract a tarball and run directly (e.g. Firefox) then put it into /opt/. A program that just needs one directory and will get all files/libraries relative to that directory can get one directory for itself in /opt/.

Another suggestion is,

Install unstable programs like firefox devel in /home/user/opt/ makes it a lot easier to remove, and no confusion for other users as to what version they should use... So if it is not a program for global use, install it in a subfolder in your home directory.


Never install programs in /usr/, it is likely to cause chaos, things installed in /usr/ is meant to be for distribution packages only. /usr/local/ is for packages locally compiled. And the srtucture works in exactly the same way! files in /usr/local/ will be prioritized over files in /usr/

/opt/ should be used for installation of pre-compiled (binary) packages (Thunderbird, Eclipse, Netbeans, IBM NetSphere, etc) and the like. But if they are only for a single user they should be put in your home directory.

If you want to be able to run a program installed in a "weird" location (like /home/user/opt/firefox/) without typing the whole path you need to add it to your $PATH variable, you can do this be adding a line like this in your /home/user/.profile

export PATH=/home/user/opt/firefox:$PATH

The folder name should be the one where the executable file you need to run is located.

References:
https://askubuntu.com/questions/1148/when-installing-user-applications-where-do-best-practices-suggest-they-be-loc



No comments:

Post a Comment