01.10.2020

Installing Ubuntu/Debian Programs Using the Batch Manager

One of the most difficult tasks that arise during the installation of Unix programs is dependency tracking.

Any more or less complex program in its work uses the capabilities provided by other modules, system libraries, etc. Thus, a dependency appears — if we want to install program «A», which uses the libraries of program «B» when working, we must first install program «B» (which, in turn, may have its dependencies). Thus, the more programs and dependencies appear on the server, the more difficult it is to track and manage them. The good news is that you can do this with the APT package manager (Advanced Packaging Tool).

Installation using the package manager

The evolution of methods for installing and managing software packages over time has come to the use of package managers that are tightly integrated with repositories. The repositories contain packaged program files with data on their dependencies. After installation, system repositories are already connected to the operating system: with their help, you can update the OS and install software packages that have been adapted and optimized to work with this version of the operating system.

Before starting the installation of packages, it is recommended to update the version and dependency data in the repository with the following command:

sudo apt-get update

Screenshot №1. Updating version and dependency information in the repository

If you need to clarify the name of the package that you want to install, look for a keyword manager in the local cache, for example, web server:

sudo apt-cache search web server

As a result, we get a large list of packages where this keyword is present in the description:

Screenshot №2. Keyword search

We select the package we need — in this case, it is apache2, and install it:

sudo apt-get install apache2

The package manager checks the dependencies and versions, compares them with the packages already installed through apt-get, after which it displays a list of components necessary for installation and requests permission to continue the operation:

Screenshot №3. Installing the package

Press y and wait for the installation to complete.

Commonly used package manager commands:

Installation through the Debian package

Software packages may not be distributed through repositories. For example, they may be available on developer sites. In this case, you can download the package and use dpkg (debian package) utility for installation. Using dpkg does not automatically track dependencies and download additional packages. If there are not enough programs or libraries, the installation will fail with a list of missing packages. They will have to be installed separately, for example, — get, if they are present in the connected repositories, or download from the developer’s sites and install in the necessary order through dpkg.

For example, download the installation package of the web server Nginx from the system repository with the command:

sudo apt-get download nginx

and try to install through dpkg–i filename.deb:

sudo dpkg –i ./nginx_1.14.0-0ubuntu1.6_all.deb

As a result, the system generates an error with a list of missing packages:

Screenshot №4. Error with a list of missing packages

Main options of dpkg:

Installation through script files

Installing a program involves unpacking an archive, copying program files to system directories, and, if necessary, making changes to system configuration files. All these actions can be entered into the script executable file and executed when it is run. Nowadays, such a method of installing a program is quite rare, but some developers use it. If you need to install such a package, you need to download the archive (usually a file with the extension .tgz or .tar.gz), unzip it into a separate directory on the server, examine the unpacked files, and also read the readme file, if any. The installation of the program is usually started by the script install.sh, so you need to include the attribute of the executable file with the command:

sudo chmod +x ./install.sh

then run the script directly:

sudo ./install.sh