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.

  • 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.
    – Rob
    Dec 30, 2021 at 18:58
  • 3
    Read man hier.
    – waltinator
    Dec 30, 2021 at 19:03
  • 1
    "new software must be installed in /opt" is inaccurate. /opt is merely one of several possible locations that are FHS-compliant.
    – user535733
    Dec 30, 2021 at 19:04

1 Answer 1


/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.

  • 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. Jan 2 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.