Ubuntu Package Managers on the command line help us to install & delete packages, add or remove repositories, update installed applications, search packages, and more…
What is a Package manager?
A Package manager is a tool that automates the management process ( installing, updating, configuring, and removing) of computer programs on operating systems.
Although we can use Ubuntu’s GUI package manager that is its Software manager app, many programs are only available through the command line or in the third-party repository. Apart from using Ubuntu’s default package manager such as APT in GUI, many powerful features that are easy to use in Terminal.
Ubuntu consistently uses APT ( Advanced Packaging Tool ) or dpkg for package management. This means that software can be reliably installed and uninstalled in packages. Event the GUI software manager on Ubuntu uses APT. And because of its popularity among desktops and servers than other Linux distros, a huge collection of programs are available such as additional software, applications, and drivers that can be installed with the help of just a few commands.
However, here we will not only discuss APT but also other package managers, for example, SNAP that has been another option in Ubuntu since 2014 to install the software in parallel to normal package management without conflicts. All packages that belong to the system and the desktop are still installed (exclusively) via apt.
- Ubuntu Package Managers available to use on the command line
Ubuntu Package Managers available to use on the command line
APT- Advanced Packaging Tool
APT is the default management system that was developed for Debian, since Ubuntu and other similar operating systems based on it, thus all use the APT.
We can use APT to search for program packages to install them or bring the whole system up to date. It is not just limited to this, a variety of tasks can be done using it, and here some common examples of how to use the APT Ubuntu package manager on the command line.
apt-get – package and source management
In the old systems such as Ubuntu 20.04, the apt was used along with get, however, in the latest version, we don’t need to use it for downloading and installing various packages.
Here are examples to use it:
- For updating repo-
sudo apt update
- To upgrade-
sudo apt upgrade
- Install software from repo– Syntax: [sudo] apt-get [option] Command [packg1] [packg2]
sudo apt package-name, example
sudo apt install vlc
- We can also install local Debian packages using it. One of the benefits of using apt instead
dpkgis, it automatically downloads the required dependencies by that particular Deb program we are installing. So, the syntax will be –
sudo apt ./filename, for example, to install Google Chrome using its deb package file
sudo apt ./google-chrome-stable_current_amd64.deb
apt-get dist-upgrade– updates all packages, and removes those conflicts, so that the OS can be prepared for version upgrade.
apt-cache – Show info about packages and sources
Running apt-cache will not affect or change anything in the system. Its only purpose is to show the data in the package cache or package metadata. The package cache is the internal database that stores information about all available packages.
apt-cache [Option] commando [Packg-name]
apt-cache showpkg vlc
Note– Some commands may need sudo
|Commands for apt-cache|
|add||Adds a file with package indexes to the package cache.|
|gencaches||Builds the package cache.|
|showpkg||Displays the meta-information.|
|stats||Displays statistics about the package cache.|
|showsrc||Displays information about the source code of a package.|
|dump||Displays a list of all packages available according to the package cache.|
|dumpavail||Displays a detailed list of all packages available according to the package cache.|
|unmet||Displays a list of all unfulfilled dependencies.|
|show||Displays the package information for one or more packages.|
|search||Searches the package information for one or more search terms.|
|depends||Shows a list of the dependencies of the packages.|
|rdepends||Shows a list of packages depending on the entered package.|
|pkgnames||Shows a list of package names starting with the search term.|
|dotty||Creates a list of the dependencies of the package that
|xvcg||Creates a list of the dependencies of the package that
|policy||Shows the priorities of the sources or a package.|
|madison||Shows the available versions of a package in the various sources.|
apt-search- Search packages in the repos
Many times we want to install some package but we don’t know whether that is available in the official repo or under exactly what file-name of it.
For example, we want to install the KDE connection app that is available in the official Ubuntu repo but how do we know the exact package name to use with the apt command. Thus, we will search it:
apt search "Kdeconnect"
In the same way, we can use the search command to find out other available programs or packages in the added repos on Ubuntu.
apt-mark – keep the current version
When we run the update command, the process updates all the installed packages, however, in case we don’t want to do update some particular program then there is an apt-mark command that helps us to do that. For example- we want to hold the updates for the installed Firefox version, so the syntax will be:
sudo apt-mark hold firefox
And to unhold it use:
sudo apt-mark unhold firefox
2. Snap- Universal Package Manager
Snap or Snappy is another Ubuntu Package Manager, also now available by default on all the latest versions of Ubuntu. It is a software deployment and package management system developed by Canonical to provide a universal package management platform for all major Linux distros. Primarily it meant for a server or cloud environment and also for the Internet of Things. However, now it can be found in the desktop versions and even integrated into the GUI Software Manager of Ubuntu.
Snap repository has hundreds of software packages or open-source applications that are way easy to install. The best thing is the same package available in Snap can be installed on Ubuntu, RHEL, OpenSUSE, etc. regardless of their base or code. It is because snaps packages are an image based on the SquashFS file system. All snaps are saved under /var/lib/snapd/snaps/Nameofpackage.snap . When the system is started, the current version of the snaps is mounted, the mount point is the snap directory. If the program contained in the snap package is called, the data is transparently extracted from the snap and executed at runtime. As a result, it can happen that some snaps start more slowly than programs installed via the package manager, which are stored uncompressed.
Therefore, it is possible to install the same program from the SNAP and DEB package using normal Package management without creating any conflict. Learn – Snap on Linux- Installation, update and delete commands
sudo snap install package-name– To install packages from Snap
sudo snap remove package-name– To remove the installed package
snap list --all – Will show all installed SNAP programs or packages
snap changes – Shows the progress of the installations, reinstallations, etc. of snaps.
sudo snap refresh– command refresh updates all snaps:
sudo snap refresh package-name – You can also specifically update individual snaps.
snap list – lists the installed snaps. The name, version, revision, track/channel, developer, and notes of the snap are displayed by default.
snap --help – List commands related to SNAP
3. Flatpak – Package manager
Flatpak as Ubuntu Package Manager is an alternative option to snap apps, if you don’t want to use SNAP then this package manager is a good option. Just like SNAP, we can also install various software from its library without making any conflict, even if that same software has been installed on the system using the default APT manager. Flatpak places all its required binaries, libraries, configuration files, and other files in a directory /var/lib/flatpak/app.
Thus, it can be install and use on various kinds of popular Linux distributions without any further adjustments. All the major open-source applications are available in its repository called FlatHub.
sudo flatpak update – Update installed programs
sudo flatpak install pacakge-name – To install packages available in FlaHub.
sudo flatpak uninstall pacakge-name- Uninstall apps
flatpak list– List installed programs
Here is the official documentation to know more about – Flatpak.
Ending notes- Ubuntu Package Manager
Although Snap and Flatpak are universal package manager, yet APT is a major package management system for all Debian based Linux distros because of its stability and easy to use command syntax; moreover, apart from package management, it can also do lots of things such as adding repositories, system update & upgrade… Whereas Flatpak and Snapp can only handle managing of applications. However, in the future, Ubuntu may give weightage to SNAP over APT because of its growing library and the ability of Canonical to control it.