Introduction to Ubuntu PackagesThe Ubuntu packages are a group of items (libraries, scripts, text files, license, a manifest, etc) that enable us to install a segment of software ordered in a way that a package manager will be able to unpack it and bring it into our system. Several packages are installed on our Linux system. We might be wondering where the packages come from. Many packages come pre-installed in a newly installed Linux system. Also, we have probably installed other packages for enhancing the functionalities of the system. We might sometimes want to list the packages installed on our system. We will learn how we can list the packages installed on our system in this article. We will use the Ubuntu Terminal windows to execute the commands. We can use the keyword shortcuts, i.e., Ctrl+Alt+T to start the Terminal. Ubuntu Package ManagementPackage management is one of the essential aspects of a Linux system. The package management tools and the packaging format differ from one distribution to another, but almost all distributions apply one of two tool sets. The RPM packaging tools and packaging formats such as yum and rpm are common for Red Hat Enterprise Linux-based distros (like Rocky Linux and RHEL itself). The other big family, used by Ubuntu, Debian, and related distros, uses the packaging format, i.e., .deb, and tools like dpkg and apt. There have been more package managers created for running in parallel along with the core dpkg and apt tooling: for instance, snap offers more sandboxing and portability, and Homebrew, which shifted from macOS, offers command-line tools which could be installed by single users to ignore conflicts with system packages. Listing Installed Packages with apt CommandThe apt command is a packages manager (built-in) in Ubuntu that aids us to install, update, and uninstall packages from our Ubuntu system. This command can be used for displaying the installed package list on our system. To run the apt command, we need to open the terminal window and execute the following command: ![]() The above command will list every package that has been installed on our system and installed packages as dependencies. The result shows the names of the packages with the installed releases and the architecture. We can run the following command to see whether a package has been installed or not: We can enter the following command to check the details of a particular package: Listing Installed Packages with dpkg commandThe dpkg command is used for installing, building, and uninstalling packages in the Debian operating system and its derivates. Dpkg-query can be used for listing every installed package in a system. We need to type the below command in the command-line window to list every installed package on our system: The result shows the names of the packages with the installed releases and the architecture. We can run the following command to see whether a package has been installed or not: Listing Installed Snap PackagesThe dpkg-query and apt commands don't list every package that is installed as snaps. We can separately list these packages using the snap command. We need to type the below command in the command-line window to list every installed as snaps on our system: ![]() Introduction to Debian Package Management ToolsThe Ubuntu/Debian ecosystem occupies some distinct package management tools for managing software in the system. Almost all of these packages are correlated and work on similar package databases. A few of these tools try to give high-level interfaces while some other utilities focus on offering low-level functionality. AptProbably, the apt command is most often applied member of the packaging tool's apt suite. Its main aim is to focus on remote repositories managed by the packaging team of the distribution and performing tasks on the existed packages. In general, the apt suite works by pulling details from remote repositories to a cache managed on a local system. Apt is used for refreshing the local cache. Also, it is used to change the package state. It means to install or uninstall a package through the system. The apt command in general will be used for updating the local cache and for making changes to the live system Important: In previous Ubuntu versions, the apt command was called the apt-get command. It has been up to date, but we can still know it as the apt-get command for backward compatibility or out of habit. apt-cacheapt-cache is another essential member of the suite, i.e., apt. This utility applies the local cache for querying details of the existed packages and their features. For example, any time we want to find a particular tool or a package that will implement a certain task, apt-cache can be a good choice to begin. Also, it can be descriptive of what exact version of a package will be targeted via a procedure. Reverse dependency and dependency details are another place in which apt-cache is helpful. DpkgWhile other tools were concentrated on handling packages managed in repositories, the dpkg command could also be used to work on the .deb packages. Actually, the dpkg tool is liable for almost all behind-the-scenes implementation of the above commands; apt offers extra housekeeping and dpkg collaborates with the packages themselves. The dpkg command can't automatically resolve dependencies, unlike apt. Its main aspect is the capability to implement directly with .deb packages, disjoint a package, and search for other things about its design. However, it can collect some details of the installed packages in the system, we should not utilize it as the main package manager. Update Package Cache and SystemThe Ubuntu and Debian package management tools aid to keep the available package list of our system up-to-date. Also, they offer several methods to update packages we have installed over our system. Update Local Package CacheFor package information, the remote repositories, that our packaging tools depend on, are updated every time. However, almost all tools of Linux package management are created for many historical reasons, working directly on this information's local cache. That cache requires to be refreshed periodically. It's a good thing to update our local cache of all sessions before working on other commands of the package. It will ensure that we are working on up-to-date information on the available software. A few installation commands will abort if we are working on stale package information. We can run the below apt command along with the sub-command, i.e., update for updating the local cache: ![]() The above command will show the available package's updated list inside the repositories we are tracking. Update PackagesApt differentiates between two distinct update processes. The first update process can be used for upgrading the components that don't need component removal. It can be very essential when we don't want to delete any installed packages in any circumstances. Some updates however involve substituting system components or deleting conflicting files. This process will avoid any updates that need package removal. ![]() The second process will update every package, even those that need package removal. Often, it is essential as dependencies for modification of the packages. The packages usually being deleted will be substituted by functional equivalents at the time of the upgrade process. So, it is generally safe. It is however a good thing for keeping an eye on the packages to be deleted, in case a few necessary components are marked for deletion. We need to type the following command to implement this action. ![]() This command will update every package on our system. Download and Install PackagesFind PackagesThe initial step is to find the repositories of our distribution for the packages we are looking for when downloading and installing packages. Finding packages is a single task that points to the package cache for details. To do so, we need to run the apt-cache search command. Note: Remember that we should ensure that our local cache is already up-to-date with the sudo apt update command before finding the packages.It doesn't need sudo privileges because this process only queries for details. Any search procedure implemented will check on the package names and the package full descriptions. Installing Package using the ReposWe can execute the apt command along with the install argument for installing any package through the repository and necessary dependencies. For this command, the arguments should be the name of the package or names because they are labeled inside the repository. We can also install more than one package at a time that our isolated by a space. If our requested package needs extra dependencies, these will be printed on the standard output and we will be prompted for confirming the process. In that case, we can continue by clicking the "Y" button or cancel with the "N" button. Installing a Particular Package Release from ReposIf we want to install a particular release of a package, we can give the release we would like to target with =, as follows: |