How to get and copy the list of installed packages on Ubuntu/Debian Linux Server
HOW TO GET AND COPY THE LIST OF INSTALLED PACKAGES ON UBUNTU/DEBIAN LINUX SERVER
In this article, we will look at the commands with which we will get a list of packages and find out for what purposes they are needed. How can install the packages on "server 2" after receiving a list of all the ones that are installed on "server 1"? How can use the apt command on an Ubuntu Server or Debian Server to list every package that has been installed? To view a list of every package installed on an Ubuntu or Debian Linux Server, you must use dpkg along with additional commands as follows.
HOW TO GET A LIST OF DEBIAN / UBUNTU LINUX PACKAGES?
Open the terminal application or log in to the remote server using ssh. You can get the following command to obtain the packages listed:
dpkg-query –l
A list containing the name, the current version, and a synopsis of the goal will show up in the terminal.
The apt command displays both installed and packages available to install. Pass the option to the apt command for Ubuntu OS:
apt list –installed
Packages with the most recent version and architecture are listed using this command.
HOW TO COPY AND MIGRATE PACKAGES ON DEBIAN / UBUNTU LINUX?
In most cases, it is necessary to move an installed list of packages from one server to another instead of installing and configuring each one separately. Two steps must be taken in order to accomplish this:
1. The package list that the command previously generated from server #1 should be saved.
We utilize the following to generate a file containing a list of installed packages:
dpkg --get-selections | grep -v deinstall > packageslist.txt
The "packageslist.txt" file name is an example.
2. On server #2, install the dependencies.
The file with the list of packages and versions is copied to server #2 with your ip server address. For example, for 192.168. 123.132 the command would look like this:
scp packages.txt 192.168. 123.132:~/
A command-line tool called SCP enables you to safely move files and folders between two places.
The final step is to roll the packages from the duplicated file. This is done by using the command:
apt-get install -y $(< packageslist.txt)
Completed! The package list has now been transferred from server #1 to server #2.
GET AND COPY PACKAGES LIST LINUX FAQs
You ask, and we answer! Here are the most frequently asked questions!
-
How do I List Installed Packages on Ubuntu?
- Use the following command: apt list --installed, with the commands, you can list all installed packages.
-
Can I list Installed Packages with Version Details?
- Yes, you can list installed packages with version details by the following command: dpkg -i