Deploying the application

directory-structure

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?

Best Answer

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.

Related Question