Score:0

Where do software get installed on Linux? What is the difference between /opt and /usr?

us flag

I would like to clarify the software application and libraries installation philosophy and best practices in Linux. From my understanding from the Filesystem Hierarchy Standard (FHS), new software must be installed in /opt, and that is what the package manager does. But, does the package manager also install application software in /use/local directory or just library software? For example, I installed the Eigen c++ library, which is a header file based library, using:

sudo apt install libeigen3-dev

I found Eigen files in /usr/include. But, from reading CMake documents, when I am developing C++ libraries, I should configure my CMake to install them in /usr/local (This is the default value for CMAKE_INSTALL_PREFIX)? This raises the question, why was Eigen installed in /usr/include instead of /usr/local/include? Are not the directories /usr/bit /usr/include for system applications like the commands ls and cat?

Further, what is the difference between the libraries saved in /usr/local vs /usr/share?

Many thanks in advance for your help. I hope get a clear understanding of the best practices in installing application and library software in Linux.

Rob avatar
in flag
Rob
I humbly believe there is no One answer to the question, so e.g. if you say $ whereis firefox >the answer will look something like this: firefox: /usr/bin/firefox /etc/firefox /usr/lib/firefox /usr/share/man/man1/firefox.1.gz and so simplify things you go: $ which firefox and the output will be: /usr/bin/firefox . So your stab is OK, but not definitive. Packages should always have there own specific entries and should be kept alone ;-) There is no law prescribing what folder and so on.
waltinator avatar
it flag
Read `man hier`.
user535733 avatar
cn flag
"*new software must be installed in /opt*" is inaccurate. /opt is merely one of several possible locations that are FHS-compliant.
Score:6
cn flag

/opt/ is used for 3rd party applications that provide a tar ball to extract. Generally the software is provided completely setup with correct permissions and you get an instruction to copy a service over to the system to activate it. Mysql, Apache, Jasperserver all provide alternative installs.

/opt/ is never used by the system itself as to avoid conflicts.

When software is installed in /opt/ you tend to install it with a version number in the directory name so you can install more than 1 version and use a symlink for the active one. That way you can install Mysql v8 on a system that still uses v5, test your application before committing to the next Ubuntu release.

/usr/ is part of a default Linux and is used to store parts of an install through the package manager of that system. To avoid duplicates (something windows was plagued with in older versions) Linux software in directories a large group of creators agreed on. Another benefit is that software can be smaller as you do not need to provide libraries with your software.

Ahmad Abuaish avatar
us flag
Hi @Rinzwind, Many thanks for the detailed response. Your answer helped me to understand the purpose of `/opt`. I also dug more into the FHS and understood the proper use of `/usr/local`. Software that are installed locally should be installed in `/usr/local` and software installed by the package manager will be installed in `/usr`. So, in my CMakeLists, I have to use `/usr/local/lib` and `/usr/local/include` as a destination. Many thanks again, @Rinzwind, for your detailed response.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.