Methods of payment Abuse

How to get and copy the list of installed packages on Ubuntu/Debian Linux server

  • Main
  • Knowledge base
  • How to get and copy the list of installed packages on Ubuntu/Debian Linux server
01.01.2023, 21:26

The sysadmin needs to get a list of packages for various reasons: reinstalling the system, installing packages on another machine, checking versions and compatibility, or others.

How do I get a list of Ubuntu / Debian Linux packages?

You can output packages with the command:

dpkg-query -l

A list will appear in the panel indicating the name, the current current version and a brief description of the purpose.

For Ubuntu , it is used:

sudo apt list --installed

It also displays a package listing indicating the current version and architecture. There are commands that allow you to display only a list of packages with names, but they are used less often).

How to copy and transfer packages to Ubuntu/Debian Linux?

As a rule, the system administrator needs to transfer the installed list of packages from one server to another, and not to install and/or configure each separately.

To do this, you need to perform 2 actions

save the list of packages from server #1 that were previously output by the command;

roll dependencies to server #2.

To create a file with a list of installed packages, use:

dpkg --get-selections | grep -v deinstall > allpackages.txt

Name "allpackages.txt " given for example. You can use any names: "alllists.txt ", "lists.txt ", "packages.txt "and so on.

The file with the list of packages and versions is copied to server No. 2 with your address. For example, for 200.200.200.200, the command will look like this:

scp allpackages.txt 200.200.200.200:~/

It remains only to roll the packages from the copied file. To do this, use the command:

$ sudo apt-get install -y $(< allpackages.txt)

Ready! Now you have moved the package list from server #1 to server #2.