9

When deploying my application under linux, where do I put my libraries, executable and the desktop entry file? And what about other files my program needs? For example background pictures, audio files etc.

I heard that I put my executable file in the /usr/bin/ folder, my libraries in the /opt/<myapp>/lib/ folder and my desktop entry file in /usr/share/applications/ folder. Is that correct?

But where is the general place for application resources?

Is that everything I need to care of when deploying my application or are there other steps I am missing?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Davlog
  • 313
  • 1
  • 4
  • 8
  • The question is not precise. Are you building a binary package for installation into the system, or planning to do a local installation? I assume the former, which is consistent with most of your paths except the `/opt` one. The LHS says `/opt` should not be used for binary packages that are part of the system. – Faheem Mitha Feb 09 '14 at 17:45
  • There are several Q's that are related to this topic on the site. The FHS is what often is referred to when determining where installed assets go: http://www.pathname.com/fhs/. – slm Feb 09 '14 at 18:10
  • Somewhat related: http://unix.stackexchange.com/questions/74646/difference-between-lib-lib32-lib64-libx32-and-libexec/74652#74652. Also take a look at the man page: `man hier`. – slm Feb 09 '14 at 18:12

1 Answers1

16

The Filesystem Hierarchy Standard specifies where to put files.

If you're installing files outside of the package manager, always put them under /usr/local or under /opt. Never touch anything under /usr except via the package manager, except for things under /usr/local.

  • /usr/local/bin: executables intended to be executed by users (interactively or from scripts)
  • /usr/local/lib: libraries available to many programs, not just yours
  • /usr/local/lib/YOUR-PROGRAM-NAME: any other architecture-dependent files
  • /usr/local/share/doc: documentation (except in man and info format)
  • /usr/local/share/info: documentation in info format
  • /usr/local/share/man/man*: man pages
  • /usr/local/share/YOUR-PROGRAM-NAME: any other architecture-independent files

These days, the separation of the share area which contains architecture-independent files isn't very important. It was devised back when hard disks were smaller and it was important to save space by not storing architecture-independent files twice in heterogeneous networks. You can skip this distinction if you like and put everything under lib/YOUR-PROGRAM-NAME.

If you prefer to use /opt, put everything under /opt/YOUR-PROGRAM-NAME, and make symbolic links in /usr/local/bin (and /usr/local/share/man/man* and /usr/local/share/info if you provide documentation in man and info format) so that users can invoke your program.

If you make deb or rpm packages, put files under /usr instead of /usr/local. Check each distribution's documentation for its particularities.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175