38

How do you generally proceed for your package installations on Linux, for packages that are not part of your distrib's repos?

On my side I am used to install in /opt. But since, I saw this doc on the Internet: http://www.pathname.com/fhs/. Now I am confused: apparently /usr/local would be also a possibility.

What is the difference between both? Any best practices to share?

Thanks

SirFabel

migrated from stackoverflow.com Mar 21 '10 at 18:04

This question came from our site for professional and enthusiast programmers.

31
  • Everything that has to be compiled & installed Unix-style and complies to FHS -> /usr/local
  • Everything else (e.g. a java web-application that comes with it's own applicationserver and loads of resources in a zip archive -> /opt
  • lintian do not allow packages to be installed on /opt neither /usr/local anymore – Cristiano Jan 18 '16 at 22:16
24

Just as additional interesting info: The original meaning of /usr/local is that if /usr is network-mounted (single /usr shared across multiple computers), /usr/local would be a separate filesystem local to the computer (partition on local disk).

And while on that topic, even if it's off-topic to the question: If there are multiple computers with different architectures, naturally there would be one /usr for each arch, but /usr/share would be yet another separate filesystem shared between architectures (hence 'share').

  • 4
    No... historically (yes, I was there!) /usr et al had the vendor-provided stuff, /usr/local was locally installed stuff (i.e., bash, gcc and other nice stuff). – vonbrand Jan 15 '13 at 18:54
7

The way I do it is that if it requires a prefix to itself OR it's a binary package, I go for /opt (which is pretty much the Solaris way). If i'm compiling from source /usr/local is how I go.

6

I put everything in a private directory and then use GNU stow.

So, I'll install package X.ver to /BASE/stow/X.ver. GNU stow will then combine all the packages (with symlinks) into /BASE/bin, /BASE/lib, etc.

Conflicts and removing packages are much easier to deal with.

  • I've typically used /usr/local/stow/<packagename> as the home for stow "packages", and feel like it's a good practice - if someone else looks in /usr/local it makes it obvious what's going on and what system is maintaining the symlinks. – Stephanie Jun 20 '12 at 22:51
2

Here is how I do interpret the FHS standard:

/usr/local is for locally built or locally installed files, whether packaged or not that somewhat become part of that instance of the Operating System.

/opt is a place to install "foreign" packages not part of the Operating System.

As long as you only use files on the single system where you build them, /usr/local is fine, and it is therefore the default base directory for the vast majority of open source software.

If you plan to redistribute your package, I would recommend using a custom base directory like /opt/myPackage.

1

Solaris used /opt a lot. Many modern Linux distros now expect packages in /usr/local/. The idea is the same - a place to put software that makes this machine do what it does, as opposed to the operating system. It's roughly analogous to "Program Files" on a Windows system.

Pick one and stick to it. It's easy enough to symlink /opt to /usr/local.

  • I like Lee's comment, nice way to think about the problem. It would feel a bit weird to me to have an /opt on a Debian machine, but that's probably just personal preference. – Kyle Hodgson Mar 21 '10 at 17:31
0

If you recompile a software provided by your operating system distribution, to leverage several architecture advantages specific to your very own machine, use /usr/local.

If you add a piece of software from other sources, than your operating system distribution, put it into /opt.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.