65

I understand that in Windows as well as Linux and Unix, a program|application|software can be installed in any directory. Also if packages are installed using the distribution's packaging system, it'll place files in the correct location.

But at times, a software installation prompts for a path to place files. In case of a Linux distro where is this default place (C:\Program Files or C:\progra~1 equivalent)? Is it different for various distributions? If yes, where would this be for RHEL, Suse and Ubuntu?

Thomas
  • 1,693

7 Answers7

60

The Linux Documentation Project has a description of the Linux filesystem hierarchy where they explain the different folders and their (partly historical) meaning.

As xenoterracide already pointed out /bin and /opt are the standard directories which can be compared to "Program Files" on Windows.

/bin contains several useful commands that are of use to both the system administrator as well as non-privileged users. It usually contains the shells like bash, csh, etc.... and commonly used commands like cp, mv, rm, cat, ls.

(quoted from TLDP)

/opt is reserved for all the software and add-on packages that are not part of the default installation. For example, StarOffice, Kylix, Netscape Communicator and WordPerfect packages are normally found here.

(quoted from TLDP)

Axel Knauf
  • 1,074
  • 7
  • 5
  • 9
    Isn't /opt only used for packages that are not contained in the repos? The application folders for inkscape, gimp, rhythmbox etc. are located in /usr/share. Wouldn't that rather be the equivalent? – c76c3r8c42b347r8 Sep 11 '11 at 13:33
  • 5
    See http://www.linuxfoundation.org/en/FHS for more recent info on the filesystem hierarchy (FHS). (Note: The site is down at the moment but should be back up shortly). – jw013 Sep 11 '11 at 16:20
  • @Toxicbits: At least on Gentoo in /opt there are binary packages - especially those which cannot be installed to /usr due to nonstandard filesystem hierarchy. – Maja Piechotka Sep 11 '11 at 18:10
  • TLDP seems great! Well, on a side note; the first time I saw TLDP, I thought: "too long didn't... peak? what?" – Ege Özcan Sep 12 '11 at 09:10
  • 3
    This is incorrect. /bin contains only executable programs. The Windows Program Files directory contains a subdirectory for each installed application, which contains all of the executables, dlls, data files, and everything else needed by / shipped with the application. – psusi Mar 09 '12 at 03:01
45

There is no direct equivalent. The directory structure is very different. Under Windows, you have a single directory for each installed package/software that contains all the files related to (e.g. C:\Program Files\MyProgram). Under Linux each software is "dispersed" in many directories according to file type and some other rule.

As an example, we can examine where different files related to xscreensaver program are installed:

/etc/pam.d/xscreensaver
/etc/xscreensaver
/etc/xscreensaver/README
/usr/bin/xscreensaver
/usr/bin/xscreensaver-command
/usr/bin/xscreensaver-demo
/usr/bin/xscreensaver-gl-helper
/usr/share/X11/app-defaults/XScreenSaver
/usr/share/applications/xscreensaver-properties.desktop
/usr/share/doc/packages/xscreensaver
/usr/share/doc/packages/xscreensaver/README
/usr/share/locale/ca/LC_MESSAGES/xscreensaver.mo
/usr/share/locale/da/LC_MESSAGES/xscreensaver.mo
/usr/share/locale/de/LC_MESSAGES/xscreensaver.mo
[ ... ]
/usr/share/locale/zh_TW/LC_MESSAGES/xscreensaver.mo
/usr/share/man/man1/xscreensaver-command.1.gz
/usr/share/man/man1/xscreensaver-demo.1.gz
/usr/share/man/man1/xscreensaver.1.gz
/usr/share/man/man6/xscreensaver-gl-helper.6x.gz
/usr/share/pixmaps/xscreensaver.xpm
/usr/share/xscreensaver
/usr/share/xscreensaver/glade
/usr/share/xscreensaver/glade/screensaver-cmndln.png
/usr/share/xscreensaver/glade/screensaver-colorselector.png
[ ... ]

Do not worry, usually when a installer asks where to install to, the correct answer is one of the following: /, /opt, /usr, /usr/local

As you can see, quite all(1) files of xscreensaver are installed under /usr according to some simple rule: executables in /usr/bin, manual pages in /usr/share/man, documentation in /usr/share/doc/packages/PROGRAMNAME and so on.

When an installer asks for a installation prefix, usually it wants to now the base path under which install the program. In my xscreensaver example, it is /usr.

As simple rule: / should contain only program that are needed to boot the system (as C:\windows\system32), /usr/local should contain the programs that are needed only on that unique computer, /opt(2) all the optional programs that have non standard directory structure and /usr all the standard software.

In any case, it exists a standard that defines all these rules in detail: Filesystem Hierarchy Standard

(1) system-wide configuration files must reside in /etc

(2) quite obsolete under Linux

andcoz
  • 17,130
  • /opt is preferred for third party software over /usr/local for quite some time. – Steve-o Sep 11 '11 at 10:30
  • 9
    Just an explanation, /usr/share is called "share" because it is shared between different architectures (documentation, scripts, images), while /usr/lib* is for architecture-dependent files (and not executables, which to /usr/bin). – eudoxos Sep 11 '11 at 16:26
12

Ususually, /bin, /usr/bin, /usr/local/bin, or /opt/bin. I think /usr/bin and /opt/bin are the closest to Program Files, because usually they are for non system critical binaries that are installed by the system administrator, though unlike windows both of these contain programs installed with a package manager. Where /usr/local/bin is for non distro packaged software. /bin is for system critical binaries like /bin/sh.

xenoterracide
  • 59,188
  • 74
  • 187
  • 252
  • why four options? /bin, /usr/bin, /usr/local/bin or /opt/bin. Isn't there one standard location? The reason I ask is because I'm installing software on a few VM's and the default location takes to which ever partition has the largest space. I want to change the partition space to the directory where the software usually go to and not have the software placed differently in all the VM's. – Thomas Sep 11 '11 at 09:15
  • 1
    the standard specifies multiple locations idk why pathname is down but here's a link to the cached FHS which goes into more definition about what these are, and really it depends a lot on what you are installing. Also RHEL, Suse, and Ubuntu are different so they may put the same thing in slightly different locations. /opt for example is usually used for proprietary software. – xenoterracide Sep 11 '11 at 09:30
  • Also usually... typically those are all on the same partition... sometimes /usr/ is a separate partition. – xenoterracide Sep 11 '11 at 09:38
  • 1
    Some people (e.g. the Hurd project) argue that the /bin and /usr/bin discrimination is obsolete now; historically, system-critical stuff would be in /bin, /lib, ... (directly in the root), while /usr (with /usr/bin, /usr/lib, ...) would be mounted later (perhaps over network), not being necessary for basic system functionality. – eudoxos Sep 11 '11 at 16:29
  • 1
    @Thomas, /opt shouldn't exits. Some people used to think in the past that it was a good idea to have some applications in a different location from all other apps. /bin is on the root partition. Since on some system, the space on the root partition is limited, non-essential binaries (i.e. all user applications) were moved to /usr/bin. – Jan Sep 12 '11 at 20:11
  • Latest standards recommend /opt/packagename. I have not seen /opt/bin being advised. And disagree that it's "obsolete" or "shouldn't exits": if a webpage serves me a program as a self-contained archive - without an install script to split each part to /usr/local - it seems easier to put it in /opt/packagename, not split it myself. /opt fulfils this just fine. – underscore_d Nov 04 '15 at 21:48
8

Take a look into man hier it's a "Description of the file system hierarchy".

vasily-vm
  • 720
5

As others have pointed out, programs installed through the package manager are scattered over several directories. While the binary is typically found /usr/bin, the system-wide configuration files are in /etc, and so on.

If an application is not installed via the package manager, the files should be installed in a place where they do not interfere with the package manager. This place is /usr/local.

If you are asked for an installation path, the most common choice would be /usr/local/appname

Jan
  • 573
3

Type echo $PATH in your terminal to see the path(s) the shell will look in to find a command. It goes checking for a file in the order it is printed.

Kevin
  • 40,767
Jaseem
  • 146
1

Well you wont find all your solutions in /bin and sbin because they hold mostly system commands (i.e the commands used by the system).

/usr/bin can be ideally called the "Program Files" of unix world. Regarding /opt very few packages opt to use that location for installation, same applies to packages using /etc/ or /var as locations