0

In MacOS, an application is a folder, either in /Applications if installed system-wide or ~/Applications if installed only to a specific user, that contains a MacOS directory that contains the executable, a Resources directory that contains any assets or extra resources an app needs to run. There are also other files such as Info.plist or Pkginfo.

My question is what is the Ubuntu structure for applications? According to this the executable is stored in /usr/bin or something. But that seems to be just the executable. Where do apps store the assets, such as the dock icon, game textures, etc.? Or any other data that is part of the app but not the executable? On Mac apps seem to be self-contained packages but not on Linux. How are all the components of the application structured in the file system?

P.S. I was expecting this to be a mega-duplicate but for whatever reason all my searches turned up dry except for the linked question.

CPlus
  • 109
  • 1
  • 8

1 Answers1

3

The file structure of an installed Linux application can be rather complex. Files of the application (applications, libraries, data, configuration) are not contained under a specific directory, but scattered over the system file structure according to conventions, written out in the Filesystem Hierarchy Standard.

Containerized applications (Snap, flatpak, Appimage) will have all of their executables, libraries, data and configuration under specific directories or in single image files. When a containerized package is run, it is exposed to that file system as if that were the real root file system of your computer.

Each application is started with an executable, used to launch the program. Commonly, the executable is installed in a directory that is listed in the $PATH environment variable. You can see the contents of the PATH environment variable with the command printenv PATH.

  • For DEB installed programs (e.g. using apt), system executables go under /usr/sbin, other executables go under /usr/bin.
  • For manually installed (e.g.compiled) programs, the recommendation is to place these under a different directory that is not controlled by your package manager, i.e., /usr/local/bin or sbin.

Executable binaries and private libraries of a third-party program are commonly placed under /opt, fully distinct from the core operating system components. Typically, executables from under opt/ are either linked into /usr/local/bin, or a wrapper script is placed there so that these "optional" programs also can be launched conveniently by typing a name at the prompt.

Shared libraries, i.e., libraries commonly used by different applications, are typically stored under /usr/lib, those of compiled programs under /usr/local/lib.

Configuration files commonly go under /etc.

Program data (logs, databases, cache, …) used during execution is under /var.

The whereis command can give you an idea of where files of an application live, e.g.

$ whereis firefox
firefox: /usr/bin/firefox /usr/lib64/firefox /etc/firefox /usr/share/man/man1/firefox.1.gz

To find out which files were installed where by a specific package, you can use

dpkg -L $package
vanadium
  • 97,564