14

I've found out this topic : What is the difference between /opt and /usr/local?

And this link : http://www.pathname.com/fhs/pub/fhs-2.3.html

To help me understand the usages between /home, /root, /usr/local, /usr/bin and /opt, I still have a question because I'm a little confused understanding the differences between each of them.

For a system in which I want to install my applications that have to be used locally by a user, is it better to put the applications in /home or /usr/bin or /root ? Is there a "good practice" that I should know of ?

3 Answers 3

13

Well, there are various considerations.

  1. You don't put anything in /root. This is for uid 0 and systems administration only; it's often not even traversable by non-root users.

  2. Install under /home/<username> if you're an unprivileged user on the machine and you, personally, need to be able to use the software you're installing. If you're the admin, you usually shouldn't mess around with users' homedirs.

  3. Install under /usr/local for normal software packages which, for whatever reason, you're installing from source locally (instead of installing through the package manager). This is usually where things get put if you run the standard autoconf ./configure && make && make install incantation from a source tarball. I also put little utilities I've developed locally under /usr/local/bin, if I want them to be universally available.

  4. Install under /opt for third-party pre-bundled software (a good example of this is Calibre, if you use their binary installer). This makes a separate directory under /opt for every package you install, and that directory has all the requisites for the package (as opposed to /usr or /usr/local, where binaries for all the packages are under bin, libraries for all the packages are under lib, &c.). In general, if you're writing or packaging software yourself that needs a lot of different components, it might be good to put it here, but it's probably suboptimal to try to install someone else's package there, if it's not their recommendation. That can be a matter of opinion, though.

If you're creating a package that users or administrators will install manually, you want either /opt or /usr/local. If you're installing someone else's package, follow their recommendation. If you're packaging something for a distribution (which you probably aren't), use /usr.

6

A well-behaved system-integrated package puts its:

  • executables in /usr/bin
  • .so and .a libraries in /usr/lib
  • architecture-independent data (including documentation) in /usr/share
  • system-wide configuration data in /etc
  • user configuration data in a dotfile in $HOME or in $HOME/.config

If your package isn't system-integrated (e.g., what you build from source), your prefix is /usr/local instead of just /usr.

If your package doesn't follow this data separation convention, it should go into /opt.

If you don't have permissions to write outside of your $HOME, you can replicate bin, lib and share in $HOME/.local but most user-level package managers don't follow this (in my experience).

/root is just the home of the root user. You usually need not be concerned about /root if you want to put software on a system.

1

/home is the base directory for personal user homedirectories. In Windowss XP /home is comparable to %HOMEDRIVE%. The full path, normally /home/$Loginname is comparable to %HOMEPATH%.

/root is the home directory of the main superuser account. It resides on / to make it available during early boot, where /home might not be available (network share or own mountpoint).

I will not repeat what can be read in the other answers about /usr/local...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .