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?

  • 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 9 '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: pathname.com/fhs. – slm Feb 9 '14 at 18:10
  • Somewhat related: unix.stackexchange.com/questions/74646/…. Also take a look at the man page: man hier. – slm Feb 9 '14 at 18:12
up vote 11 down vote accepted

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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