80

I'm currently installing NetBeans, and the default install directory is /home/thomasowens/netbeans-6.8. I'm not a fan of that location, so I'm looking at /etc, /bin, /usr/bin, and /sbin. Does Linux have a place that, by convention, is the same as Windows' C:\Program Files directory?

7 Answers 7

109

According to the Filesystem Hierarchy Standard, there are several places that are acceptable, depending on the application. I'm quoting from it extensively here.

  • bin is short for "binary" of course
  • sbin is short for "server binary", otherwise defined as:

    Utilities used for system administration (and other root-only commands)

  • /usr is for shareable, read-only data, and should be shareable between various FHS-compliant hosts (if you have lots of machines on your network, and they're all the same architecture, you should be able to share a single /usr folder with every machine on the network)

  • /usr/local is for use by the system administrator when installing software locally (ie, for applications installed only on this machine, not on every machine on the network).

Taking these together:

  • /usr/bin is the primary directory of executable commands on the system.
  • /usr/sbin is for any non-essential binaries used exclusively by the system administrator.
  • System administration programs that are required for system repair, system recovery, mounting /usr, or other essential functions must be placed in /sbin instead (ie, the things you need to access in order to mount /usr/sbin go in /sbin)
  • Likewise, essential user commands that may be needed before /usr is mounted go in /bin
  • Anything installed only on the local machine should go in /usr/local/bin or /usr/local/sbin

There's one other use for /usr/local though. Most things that you install through your distro's package manager will be placed under /usr; many people put things they've compiled by hand under /usr/local instead. This keeps them out of the way of the package management system and lets you spot what you installed from the distro (and don't need to back up because you can grab it again) and what you compiled by hand; it also lets you run different versions at the same time (eg, /usr/bin/firefox vs /usr/local/bin/firefox).


Just when you thought things were settled, there's one other place, which is probably the closest equivalent of c:\Program Files - /opt:

/opt is reserved for the installation of add-on application software packages.`

/opt is probably the closest equivalent to c:\program files, in that it's the one place you'd expect to find an application with all its files together in one folder, rather than scattered across /usr/bin, /var, and /etc. It's usually only used by very large packages, but in this case, given that Netbeans wants to have its own folder, it probably makes the most sense to put it under /opt/netbeans

4
  • 3
    interesting. if I had designed Linux I would have put the network shared apps in /usr/shared and then put the privately local host apps in /usr . that way i could share /usr/shared without also , through inheritance, sharing /usr .
    – djangofan
    Jan 2, 2010 at 22:39
  • 1
    Really nice answer. I also like the comment about keeping things out of the way of the package management system. Jan 3, 2010 at 1:24
  • 1
    Definitely /opt for "full 3rd-party packages". Most installs will divide up the various binaries, libraries, files, etc. into different directories, but when you have an "all in one" directory, /opt makes it easy to deal with. Jul 2, 2014 at 19:23
  • Couple quick questions: 1) If /usr is supposed to be shareable among all machines on a network, doesn't that mean that all child directories would also be shareable, thus making /usr/local visible to other machines on the network? 2) What is FHS 3) When you talk about commands necessary for mounting /usr, are you talking about the how the OS boots up from, say, a shutdown? I apologize for the bombardment of questions 7 years later, but I'm new to Linux and had this same question after seeing install guides say where to put stuff, but not WHY to put it there. +1 btw
    – Ungeheuer
    Feb 23, 2017 at 7:16
6

Really it comes down to personal preference. I'll explain mine for what it's worth.

/usr, /usr/bin are usually places for software installed by the system to be installed. When I install things myself, I install them in one of several places:

  1. If it's a script or small program only I will use, I install it in ~/bin - this is where most of my stuff ends up.
  2. If it's something like you described (NetBeans) with a full file tree of its own, I install it in /opt
  3. If it's a single executable, I install it in /usr/local/bin

Why do I distinguish between #2 & #3? No idea, it's just a habit that I've developed over time. It does work out that /opt usually ends up becoming a deep tree of files, but has only 2 or 3 actual 'things' installed. At this moment, I have lampp and lotus notes installed in opt, 2 directories that each have rather large trees beneath them. In /usr/local/bin, I have 20 or 30 entries, but no subdirectory.

I don't install things in /usr/bin or /usr/sbin because I like to keep things that I add manually (not part of simply installing from the standard repository) separate.

2

While the Filesystem Hierarchy Standard does provide some guidance. I've found that most distributions like to install packages into /usr/share.

Because of this, I've adopted the practice of installing any application not installed via package manager (rpm / apt-get / emerge) in /usr/local. This allows me to keep applications and libraries that aren't managed via package management separate from those that are.

It's a technique that has helped me manage my system under both Fedora Core and Gentoo.

0

I would have thought that the default location is /bin, it is where pretty much everything gets installed by default if using apt-get or similar...

... However, when it comes to more modern programs (or ones without an installer) that have a lot of additional files, I like to place them in their own directory within /bin.

1
  • 3
    What is the difference between /bin, /usr/bin, and /sbin? /bin makes the most sense, since it's for BINary files. Jan 2, 2010 at 20:26
0

Usually they install in multiple folders, mainly /usr, /local, /bin, etc. You can find out where the program installs to from the GDebi Installer (under the files tab). If you're going to move Netbeans, I'd suggest moving it to /opt, because that's where Google seems to install its stuff.

0

Agreeing with James Polley's answer, but in fact the default directory makes a lot of sense unless you need to share the application between multiple accounts. I, for instance, needed to install Eclipse 3.0 (obsolete) in order to do Flex work under Linux, and I put it in $HOME/eclipse3.

0

I like to use /apps for most add-on apps that I install on multiple servers. I keep a copy of the folder in /installs/apps on my nfs server. When I create any new linux server I mount the installs folder and copy /apps and I have many different common apps on the new server. I delete those entries I don't need for this new server and I'm done. Well, maybe I need to run a script or three for setting environment variables or path statements but that's pretty much what it takes to set up many new servers.

I come from a Windows and .net background. One of the promises of .net was that most apps could be installed by using Windows xcopy. I look for the same thing in Linux. Where available, I choose the tarball over the RPM or yum, etc. so I can deploy to /apps with cp -r and add the app to my nfs server for future deployments.

1
  • 2
    The question asks for the convention. You described what you do, personally. Can you at least relate this to a convention?
    – fixer1234
    May 29, 2016 at 16:26

You must log in to answer this question.

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