In many online forums, I have come across custom installation made in the following paths:
/opt
/usr/local/bin
/usr/local/src
/usr/local/include
This begs the question, what is the correct path for performing custom installations?
Opt vs Usr
n Red Hat Linux, custom installations typically belong in the /opt
or /usr/local
directories. Here’s how you can use these directories:
/opt
: This directory is intended for the installation of add-on application software packages. A package placing files in/opt
must locate its static files in a separate/opt/<package>
or/opt/<provider>
directory tree, where<package>
is a name that describes the software package and<provider>
is the provider's LANANA registered name. This is useful for standalone or third-party software applications that aren't part of the standard operating system distribution./usr/local
: This directory is for use by the system administrator when installing software locally. It should have the same subdirectories as/usr
. This directory is typically used for software installed from source, or software not provided by the official distribution repositories. It’s the traditional place for locally compiled binaries, libraries, etc.
Both directories are used to avoid conflicts with the files managed by the package management system, and to ensure that non-standard software does not overwrite files from the base system.
Which Usr Directory
or custom installations on a Red Hat Linux system, the placement within the /usr/local
hierarchy depends on the type of files being installed. Here's how these directories are typically used:
/usr/local/bin
: This directory is intended for executable programs installed for use by all users. If you're compiling and installing a program from source, the executable files should generally be placed here./usr/local/src
: This directory is intended for storing source code. If you download or create source code for custom software, it's a common practice to place the source code here before compiling and installing it./usr/local/include
: This directory is used for storing header files used in C and C++ programming. If your installation involves custom libraries that need to be included in other programs, the associated header files should be placed here./usr/local/lib
: Although you didn't ask about this directory, it's also relevant. It is used for storing library files that are used by the executables in/usr/local/bin
.
Here’s how you might use these in context:
- If you are compiling a program from source, you might download and extract the source code to
/usr/local/src
. After configuring and compiling the software, you would install the binaries (executables) into/usr/local/bin
, libraries into/usr/local/lib
, and header files into/usr/local/include
.
This organization helps maintain a clear separation of source files, binaries, libraries, and header files, adhering to traditional Unix filesystem hierarchy conventions.