I've been scratching my head over the File System Hierarchy Standard recently and in numerous occasion, when talking about the /usr/local
directory, I came across the term "locally installed packages". Could someone please explain what is exactly meant by "local" in this context?

- 927
-
Have a look to: https://unix.stackexchange.com/questions/11544/what-is-the-difference-between-opt-and-usr-local – jlliagre Oct 01 '17 at 13:59
2 Answers
A locally installed package under /usr/local
, or /opt
per the FHS standard, means packages not installed by the default distribution, but packages installed specifically for that system.
The directories
/opt/bin
,/opt/doc
,/opt/include
,/opt/info
,/opt/lib
, and /opt/man are reserved for local system administrator use. Packages may provide "front-end" files intended to be placed in (by linking or copying) these reserved directories by the local system administrator, but must function normally in the absence of these reserved directories.Programs to be invoked by users must be located in the directory
/opt/<package>/bin
or under the /opt/ hierarchy. If the package includes UNIX manual pages, they must be located in/opt/<package>/share/man
or under the /opt/ hierarchy, and the same substructure as/usr/share/man
must be used.Package files that are variable (change in normal operation) must be installed in
/var/opt
. See the section on/var/opt
for more information.Host-specific configuration files must be installed in /etc/opt. See the section on /etc for more information.
No other package files may exist outside the
/opt
,/var/opt
, and /etc/opt hierarchies except for those package files that must reside in specific locations within the filesystem tree in order to function properly. For example, device lock files must be placed in/var/lock
and devices must be located in/dev
.
The packages in question can be installed either by the sysadmin, or given the appropriates rights, by other users.
Frequently, these applications are locally compiled or run as scripts, but there are alternative methods for deploying them, such as distributing pre-compiled binaries or packages to a defined set of servers. In cases where a system administrator is responsible for the installation, they can compile and package the application in adherence to the distribution standards, like using Debian's .deb package format. Additionally, I maintain local repositories for this purpose.

- 56,709
- 26
- 150
- 232
-
In the Linux world, packages installed from a distribution repository using a package maintainer, although "locally installed" are usually not considered "locally installed software", and does not go into
/usr/local
. (Insert rant about Linux systems not having a base system in the same way as the BSDs have). – Kusalananda Oct 01 '17 at 07:19 -
@Kusalananda If packages break rules, it is not Linux fault, but indeed, I have seen (many) local packages out of place. I had forgot about /opt – Rui F Ribeiro Oct 01 '17 at 07:43
It means different things to different Unices.
The FHS says nothing about "packages" in relation to /usr/local
but instead describes it as a "tertiary hierarchy for local data, specific to this host".
On most Linuxes, a local administrator may install locally compiled software from sources other than the Linux distribution in use into
/usr/local
. The distribution's package manager will not use/usr/local
.Packages installed from a package repository using
apt
,apk
,yum
, etc., are not considered "specific to this host".BSD systems have a "base system" consisting of utilities and services that are needed to run the system. Software installed with the operating system's package manager will therefore be installed under
/usr/local
,/usr/pkg
(NetBSD),/opt/homebrew
(Homebrew on non-Intel macOS), or someplace else, away from the base system's/usr
directory hierarchy (seeman hier
on your BSD system).BSD systems consider locally installed software to include 3rd party packages installed by a local administrator, even though they may be installed with the system's package manager. Locally compiled software (in the Linux sense) should probably be installed elsewhere, for example, under
/srv
or/opt
, as not to accidentally clash with maintained software in/usr/local
(varies with BSD flavour, see above).Packages installed from a package repository are considered "specific to this host".

- 333,661
-
Indeed about the packages coming from official repos, however nothing prevents you doing you own/local ones, and I have got a couple here. It was meant to stress out nowadays the definition of local packages, with the devops movement, may no longer means deployed just for that server. – Rui F Ribeiro Oct 01 '17 at 09:52