I do not have programming experience, but I understand how a shell script works theoretically. There are only two steps important to make a script executable,

  1. I have to tell the shell how to interpret the contents of the script by writing a #!/path/to/interpreter,
  2. I have to give the permission to execute the file by chmod +x filename.

So far, I can understand it, but how do "real" programs that contain many files and are zipped in a .tar.gz package differ from this kind of installation, what are important steps the Linux needs to do behind the curtain in order to make the program executable? Or in short: What is the very meaning of installing in Linux ?

2 Answers 2


The installation of a Unix program consists of roughly two parts.

1) Putting the files in suitable locations

2) Setting file permissions and ownerships suitably

With regard to the first, the Linux File Hierarchy Standard is relevant. This is Linux specific, but largely follows historically codified Unix rules. Specifically, binaries intended to be run by the user are placed in /usr/bin, system level binaries for adminstration etc. are placed in /bin, locally installed binaries are typically places in /usr/local/bin, etc. These are places that the system looks where to look at runtime, based on the PATH, variable, which on Debian is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin. Similarly, libraries are placed in specific locations, /usr/lib, /lib, /usr/local/bin etc. following similar rules. Again, by default, the system is designed to look in these directories at runtime.

There are other specified locations for placing documentation (including man pages) and data files, but these are not so critical to system functioning.

As regards the second, files in the different parts of the system have different ownerships and permissions. While most files are owned by root, the associated group varies.

The actual machinery of an installation varies, but is usually handled by the install target of a build system. The most common build systems for free Unix-like systems like the Linux-based systems are Autotools and Cmake.

There is also usually an extra layer. Normally Linux systems have a binary package manager. These packages are usually built by invoking the installation target, but instead of installing the files into the system, they are installed into a temporary directory as part of the process of building the binary package. For Debian, this is usually the debian/tmp subdirectory of the source directory.

Installing a binary package into the system has numerous advantages over a local installation, notably tracking which files belong to which package/software, and also handling package/software removals in a clean and reliable way. While build systems may have an uninstall target, this is not such a reliable way of handling uninstalls.

  • A compatible (and imho very clever) alternative is the way programs are installed in gobolinux, see gobolinux.org/index.php?page=at_a_glance
    – loreb
    Feb 20, 2015 at 17:29
  • 1
    @loreb this seems like a form of sugar to me. Since the alternative locations are just a bunch of symlinks which map to the usual locations. Not sure what the point is. Feb 20, 2015 at 22:39
  • It's also sugar, but not only that: it means you no longer need to worry if awk is /bin/awk or /usr/bin/awk, but it also simplifies installation/upgrade dramatically (install to a directory, THEN symlink), allows having multiple versions installed if needed, etc. Also, you have it backwards: {/bin,/usr/bin,/usr/local/bin,...}/bash are symlinks to /Programs/Bash/$version/bin/bash, and /bin,/usr/bin,/usr/local/bin are all symlinks to the same directory.
    – loreb
    Feb 21, 2015 at 12:56

Installing a program is done by the operating system's package manager. So depends on the OS (Linux is the kernel).

E.g. Debian is a Gnu/Linux, it used apt to install deb packages. Redhat, suse, Freebsd. etc use different package managers.

In essence they will copy files to where they need to be (somewhere that normal users can not change), and set permissions as appropriate. It will also adjust appropriate configuration files.

There is no magic to it, the stuff behind the curtains is just tracking, to make it easier to un-install.

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.