Software for Linux distributions are often classified as "Packages," or software composed of many files that are packaged into one. This is similar to how Windows programs often have installer executables, where after the installation is complete, a folder (often in the :C/ directory) is created that contains all of the files necessary for the program to function properly. In many Linux distros, we rely on "repositories," places where packages are uploaded and maintained, in order to both install our software and keep it updated.
There are many repositories that exist, and each repository contains different packages, and some repositories may overlap packages with other repositories. When you first install any Linux distro, it often comes with a certain amount of default repositories to choose from. These are located in /etc/apt/sources.list. Therefore, if you find yourself trying to sudo apt install some package but it isn't working, it is likely that the repository containing the package is not located in sources.list. Additionally, another reason a package might not install is that you are missing dependencies from your system, where the package you are installing could be dependent on either other packages or libraries.
Installing Packages without Repositories
Starting out, you may not install directly from packages but instead from the distributor's website. You will typically download either a .deb file for Debian-based systems or a .rpm file for Redhat-based systems. The package managing command for both systems is dpkg and rpm, respectively.
In order to install a package, open up your terminal, cd into the directory that contains the .deb or rpm file, and input the command:
dpkg -i package.deb
rpm -i package.rpm
Note that -i stands for install. Similarly, if we wanted to remove a package, we would input
dpkg -r package.deb
rpm -r package.rpm
Installing Packages from Repositories
The other way to install packages would be to install them from the repositories located in sources.list. The two main tools for this are abt for Debian-based systems and yum for Redhat systems. It is always a safe practice to update your repositories consistently like so:
If you'd like to install directly from remote repositories listed in sources.list, you can input the commands:
apt install package
yum install package
Lastly, if you'd like to remove packages, you can do it like so:
apt remove package
yum remove package
Solidifying the Difference
We can see that dpkg and apt ( as well as their Redhat counterparts) are fairly similar, yet they have distinct, important differences to be aware of:
dpkg will install a downloaded .deb file from the distributor's website. It will not install any packages from repositories located in your sources.list file, and it will also not install any needed dependencies if you are missing them.
apt, however, is able to install packages straight from any repositories located in sources.list. It is also able to locate any dependency problems, and if it detects one, it will also install the package that is missing (provided the missing package is also located in a source repository).
Adding additional repositories
Surprisingly, add-apt-repository, which we will be using to add additional repositories to our sources.list, may not be included by default in some Debian-based Linux distros. To make sure it is installed, open up a terminal and input the commands:
sudo apt update
sudo apt install software-properties-common
The format for add-apt-repository is as follows:
add-apt-repository deb *repository url* *distrobution code name* *component*
where the *stars* are self-explanatory, but the *component* aspect is the repository component, which is often stated on the repository page.
Please sign in to leave a comment.