After reading this tutorial, you will know how to find information about installed, removed, and upgraded packages using commands apt, dpkg-query, and reading dpkg logs. There are instructions to create a list of installed packages, install all listed packages on a new computer, and additional apt and dpkg tips.
See installed packages using apt
The command below prints a list of all software installed through the apt/apt-get packages manager.
Listing installed packages with dpkg-query
dpkg-query is a command to display information on packages from the dpkg database.
Count all installed packages
Using dpkg-query, you can get a total count of all installed packages. The -f flag will list all binary packages only, then the wc command counts all listed packages:
As you can see, there are 2802 installed packages.
See installed packages reading logs
You can read recent apt activity (installation, removal, upgrade) by reading the log /var/log/apt/history.log as shown below:
To get information on packages installed using dpkg, you need to read dpkg logs located at /var/log. You can read the current log by running the command below:
To check the previous log, see the file /var/log/dpkg.log.1.
Reading compressed logs is the same process but with zgrep instead of grep, as shown in the example below.
If you want to see all compressed logs at once, you can use a wildcard like in the following example:
List removed packages
You also can list removed packages by reading logs by replacing “ install” with “remove”, as shown in the image below.
As with the previous example, you can also use the zgrep command and a wildcard to read all compressed logs, as shown in the screenshot below.
List upgraded packages
To show upgraded packages replace “install” or “remove “ with “upgrade”, as shown in the example below.
Use zgrep to read compressed logs.
As with previous examples, you also can use a wildcard.
Export list of installed packages to install on a new device
You can create a list of installed packages, then import it to a new device to install the same software.
To create a list of installed packages, you can do a similar procedure as the one used to count installed packages, as shown below. Instead of counting, the following command creates a list called installedpackages.
On the computer you want to install the same packages run:
In the screenshot below, the apt was executed on the same computer the list was created; thus, it detected packages are already installed.
Updating outdated packages
You can use the command apt to check for outdated packages to update by running the command below:
Fixing dependencies or broken packages
To fix dependencies or broken packages, after running apt-get update, execute the command below.
About apt and dpkg
- APT (Advanced Package Tool) automates packages retrieval, configuration (including dependency resolution), and installation. It can be considered the main packages manager in some Debian-based Linux distributions (including Debian itself) or a front-end for the dpkg packages manager.
The main advantage of APT over DPKG is its ability to resolve dependencies and track updates. Apt is also used for package removal, updates, and this tutorial to retrieve information. - DPKG is the Debian package manager used by APT. As said previously, while it is a lot better than compilating, it has disadvantages before APT. It handles individual packages and doesn’t resolve dependencies. Still, DPKG includes interesting tools like the dpkg-query mentioned in this tutorial. Other tools include dpkg-split, dpkg-statoverride, dpkg-trigger, dpkg-divert. Dpkg include the following development tools: dpkg-source, dpkg-gencontrol, dpkg-shlibdeps, dpkg-genchanges, dpkg-buildpackage, dpkg-dist and dpkg-parsechangelog.
For additional information on the apt/apt-get packages manager, visit the man page https://linux.die.net/man/8/apt-get.
For additional information on dpkg, visit the man page https://linux.die.net/man/1/dpkg.
Conclusion
As you can see, showing installed, removed and upgraded software is an easy task any Linux user level can execute with a few commands. Linux offers a variety of versatile commands and tools to manage and administrate packages in a custom way. For example, getting the total count of installed programs in Microsoft Windows may be harder or impossible without the help of an external tool.
Learning simple tasks like the explained in this tutorial may save you a lot of time, as proven in the section describing how to export a list of packages to install on a new device, especially useful when you need to create a similar serverand cloning isn’t an option.
Learning to administer and manage packages is key and basic knowledge any user must-have.
I hope this tutorial was useful. Keep following Linux Hint for more Linux tips and tutorials.
from Linux Hint https://ift.tt/3dRLcAf
0 Comments