Apt is a popular package manager for Debian/Ubuntu Linux systems that allows you to easily download, install, update, upgrade, remove and manage packages. When you install a package or software in Linux, there might be other dependencies (packages) that need to be installed for your desired software to work properly. So when you install packages via Apt, if its dependencies are not present on your system, then Apt will not install your software or install it with errors. In this article, we will look at how to install dependencies with Apt command.
How to Install Dependencies with Apt
Apt stands for Advanced package tool that allows you to easily manage packages on your Debian/Ubuntu systems. In fact, it can also be used to upgrade your entire operating system, not just individual packages. It is smart enough to find the package you are trying to install, determine its dependencies, and install both the package as well as its dependencies for you. We primarily use apt-get command to install packages & their dependencies.
Here is the basic syntax for installing packages using Apt command.
$ apt-get [options] command
Here is an example to install libgnutls26 using apt-get command
$ sudo apt-get install libgnutls26
If there are missing or outdated dependencies it will show something like the following
The following packages have unmet dependencies: ...
Now there are two ways to proceed. Either you can manually note the package names and download them using apt-get command.
$ sudo apt-get <package_name> install
Or you can run the following command in your terminal. It will automatically resolve all dependency issues of all packages on your system.
$ sudo apt-get -f install.
To avoid dependency problems, it is advisable to run the following commands before you install any software in Debian/Ubuntu. It will update all installed packages on your system
$ sudo apt-get update
Unfortunately, apt command does not have an option to automatically download and install all required dependencies for a package. You need to determine and then install dependencies manually, or run a single command to resolve all dependency issues in your system. If you want to install package along with its dependencies, it is recommended that you use dpkg tool with -f option. In that case, you can simply use -f option to automatically install dependencies of a package. Here is an example to install teamviewer along with its dependencies.
$ sudo dpkg -f teamviewer_amd64.deb
That’s it. In this article, we have seen how to determine the missing/outdated dependencies of a Debian/Ubuntu package, and then install it. We have also seen how to do both in a single step using dpkg command. Both Apt and Dpkg have large repositories of packages and offer variety of options to manage software packages on your Debian/Ubuntu system, as per your requirement.
Also read:
How to Install Dpkg Dependencies Automatically
How to Disable Unnecessary Services in Linux
Top SFTP Command Examples
How to Use Journalctl Command in Linux
How to Grep Log File Within Time Period
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.