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/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.