Linux get all installed packages

How To List Installed Packages In Ubuntu, Debian, Kali, Mint

Ubuntu, Debian, Kali and Mint distributions uses apt-get and dpkg commands for package management. We generally use this commands to install or remove packages from Linux systems. But in some cases we may need to list and count installed packages. In this tutorial we will look how to list and count all ready installed packages in Ubuntu, Debian, Kali and Mint.

List Installed Packages and Details with dpkg

We will start with dpkg package manager in order to list installed packages. We will use -l option which will list installed packages with their details. The detailed will provide following information.

List Installed Packages and Details with dpkg

  • name the package name
  • Version the package version number
  • Architecture the package cpu architecture
  • Description brief information about package

List Installed Packages Names Only with dpkg-query

As we have seen previous example dpkg will list a lot of information. But this will be problem in some cases and we will need only the package name. We can use dpkg-query to only list package names. We also provide some regex for this like below.

List Installed Packages Names Only with dpkg-query

List Installed Packages Names Only with dpkg

We can also list only installed package names with dpkg too. We will use —get-selections option and some grep to remove lines those contains deinstall like below.

List Installed Packages Names Only with dpkg

List Installed Packages and Details with apt-get or apt

We can also use apt or apt-get inorder to list installed packages and their details. In this example we will use apt and list command by providing —installed parameter to list installed packages.

List Installed Packages and Details with apt-get or apt

Count Installed Packages with dpkg

We can also count installed packages by simply using wc command. In this example we will list installed package count with dpkg command.

Count Installed Packages with dpkg

Читайте также:  Драйвер для мфу samsung scx 4300 для windows 10

Count Installed Packages with apt-get

We can also use apt and apt-get for installed package counting like below.

Search and Filter In Installed Packages with dpkg and grep

What if we are looking for a specific package and want to list wheter it is installed or not. We can search or filter installed packages with dpkg and grep .

Search and Filter In Installed Packages with apt and grep

We can filter installed packages with apt or apt-get and grep too.

Search and Filter In Installed Packages with apt and grep

Save Installed Packages List To A File

As a system administrator we generally need to migrate, clone or setup similar systems with required packages. We can get list of installed packages and install them another system easily. We save installed package names to a file like below.

Install Packages From List File with dpkg

We can restore given file which contains package names we want to install like below. We will use —set-selections .

Источник

How to get list of installed packages on Ubuntu / Debian Linux

Just list all installed packages with a short description

Type the following command:
$ dpkg-query -l
Sample outputs:

Just want to see a list of packages only? Try:
$ dpkg-query -f ‘$\n’ -W
Sample outputs:

How to get a list of packages installed

Type the following command
$ dpkg —get-selections | grep -v deinstall
Sample outputs:

Fig.01: Show a list of packages installed

How to save a list to a text file

The syntax is as follows on server1:
$ dpkg —get-selections | grep -v deinstall > mylist.txt
Or
$ dpkg -l | grep ^ii | awk ‘< print $2>’ > mylist.txt
Now copy mylist.txt to server named server2:
$ scp mylist.txt user@server2:

How to restore a list on server2

On server2 restore installations from the mylist.txt, run:
$ dpkg —clear-selections
$ sudo dpkg —set-selections
OR
$ sudo apt-get install -y $(
Finally run the following command to remove unwanted packages:
$ sudo apt-get autoremove
Above command should restore/install packages from backups or another server. Another option is to use aptitude command as follows:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

if you have aptitude installed, this works as a search
aptitude search ‘

that said, i prefer the solutions already listed

Alternative:
( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | grep apt-get | grep install

It is not perfect but always worked fine for me.
cheers

I’m using this for years:

I’ve come across a TON of tutorials on this subject that seem to leave out the method for cleaning up the output file for parsing.

For the section:

How to save a list to a text file

The syntax is as follows on server1:

$ dpkg —get-selections | grep -v deinstall > mylist.txt

This ends up giving you a text file formatted like this:


tcpdump install
tdb-tools install
telnet install
time install
zlib1g:amd64 install

You will get gripes about “install” not being a package in APT if you skip straight to using:

sudo apt-get install -y $(

You need to get rid of all the tabs, newline chars and properly space the text of the list first. There may also be a difference in platform such as amd64 vs i386.

To do that, I’m a fan of this Perl5 one-liner:

perl -pe ‘s/\s*install\n|\:amd64/ /g’ mylist.txt > mylist.txt

This tweaks the file to look like this instead, which will actually work with that final step using «apt-get install -y» :

. tcpdump tdb-tools telnet time zlib1g .

Thanks for adding your notes. I appreciate your post.

Источник

How to check and list installed packages in CentOS Linux

How to check installed packages in CentOS

The procedure is as follows to list installed packages:

  1. Open the terminal app.
  2. For remote server log in using the ssh command: ssh user@centos-linux-server-IP-here
  3. Show information about all installed packages on CentOS, run: sudo yum list installed
  4. To count all installed packages run: sudo yum list installed | wc -l
  5. Want to save all installed packages names in a file? Try: sudo yum list installed > my_list.txt
  6. Execute the command sudo yum update to refresh package database and install updates if any.

Let us see all commands and examples in details.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Check and list installed packages with yum command

From the dnf/yum man page:

The list command dumps lists of packages depending on the packages’ relation to the system. A package is installed if it is present in the RPMDB, and it is available if it is not installed but it is present in a repository that DNF knows about. The list command can also limit the displayed packages according to other criteria, e.g. to only those that update an installed package. The exclude option in configuration file (.conf) might influence the result, but if the command line option –disableexcludes is used, it ensure that all installed packages will be listed.

Hence, to lists installed packages on CentOS, type the following yum command:
sudo yum list —installed
sudo yum list —installed | more

List all installed packages in CentOS Linux using yum

Lists all packages known to us:
sudo yum list —all
Finally, show available packages, run:
sudo yum list —available
One can count all installed packages using the wc command:
sudo yum list —installed | wc -l
sudo yum list —all | wc -l
sudo yum list —available | wc -l

Display packages list that needs updates/patching

Keeping your CentOS box secure is an essential task. One can get a list of all upgrades available for the installed packages too. Type:
sudo yum list —upgrades
sudo yum list —upgrades | more
sudo yum list —upgrades | grep -i kernel
Sample outputs:

Get a list of all installed packages with rpm command

Simply run the following rpm command:
sudo rpm -qa
sudo rpm -qa | more
sudo rpm -qa | wc -l
sudo rpm -qa | grep bash

Use rpm command to display a list of install installed packages on CentOS server

Use repoquery command from dnf-utils package

First, install yum-utils (CentOS 6.x/7.x) or dnf-utils on a CentOS 8.x:
sudo yum install yum-utils ## centos 6.x/7.x ##
sudo yum install dnf-utils ## centos 8.x ##
Sample outputs:

To check installed packages in CentOS Linux, execute:
sudo yum repoquery -a —installed

Display name, architecture and the containing repository of all nginx packages:
sudo yum repoquery —queryformat ‘%.% : %‘ nginx
List all available packages providing “webserver”:
sudo yum repoquery —whatprovides webserver
Or list all available packages providing “webserver” but only for “i686” architecture:
sudo yum repoquery —whatprovides webserver —arch i686

More on repoquery option

Custom display format created using the -qf % or —queryformat % syntax. The % is nothing but a string to output for each matched package. Every occurrence of % < >within is replaced by corresponding attribute of the package. List of recognized tags can be displayed by running
dnf repoquery —querytags
Sample outputs:

For instance, one can build fancy list as follows:
repoquery -a —installed \
—queryformat «%-%-% installed at ‘%‘ from ‘%‘»
Sample outputs:

How to check for installed packages on CentOS and backup them

One can list and backup all installed packages using the following syntax:

Источник

Читайте также:  Отключение автозагрузок windows 10
Оцените статью