What are good practices for making Linux installations?

Suppose I wanted to install some so-very-useful library of my own design and documentation/reference for it on a Linux system. Which part should go where in that case?


When in doubt about where to put things, consult the Filesystem Hierarchy Standard (a version may also be present on your system in man 7 hier). It is the go-to document for these sort of things, and most Unix-like operating systems follow it.

You will likely want to put the library that you create in /usr/lib. This is a standard location and is often searched within by programs making use of libraries. There are also /lib, /lib32, and /lib64, but you generally don't want to use these, as they are supposed to be only used by libraries essential for the system to function. Some distributions (Arch Linux, for example) have even taken the step of removing these "essential" abstractions altogether, merging everything into /usr/lib.

As for documentation, you will want to use manual pages in /usr/share/man, or general documentation in another format in /usr/share/doc (which is actually not part of the FHS, but is fairly standard anyway). If in doubt about which manual section to put your manual page in, you should consult your operating system's list of manual sections. Usually this information is contained within man man. On my system, this yields:

1   Executable programs or shell commands
2   System calls (functions provided by the kernel)
3   Library calls (functions within program libraries)
4   Special files (usually found in /dev)
5   File formats and conventions eg /etc/passwd
6   Games
7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8   System administration commands (usually only for root)
9   Kernel routines [Non standard]

On most variations of GNU/Linux, you will probably want to use section 3.

|improve this answer|||||
  • Better place non-standard stuff under /usr/local – vonbrand May 14 '13 at 20:15
  • @vonbrand - If it's packaged, most Linux distributions forbid /usr/local. – Chris Down May 15 '13 at 2:32

Here is a general abstraction on which files should go where. If you are truly just creating a library, it would indeed go in the lib directories, but if you're going to get into creating executable wrappers around those, you'll also have to get into where the other files should go, since you can't just cram everything into lib

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.