Differences between /home, /root and /usr

directory-structure

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 ?

Best Answer

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.