How to get list of Installed packages on Ubuntu 20.04

 ## Introduction: 

- Ubuntu Linux is an open-source operating system based upon the Linux kernel and GNU command-line utilities. Ubuntu Linux is extremely popular among new Linux users as well as developers all around the globe

## Listing the Installed Packages with dpkg

- To list packages that are installed, we use the “dpkg” command. To run the below command

It is also possible to list installed packages matching a given pattern. The syntax is:
dpkg -l pattern
dpkg --list pattern
apt list pattern
apt list --installed pattern

$ dpkg --list


For example:
$ dpkg --list nt*

Sample outputs:

Where:
  • ii – Indicates that package named xauth installed.
  • un – Indicates that package not installed or in Unknown status.
## Finding a Particular Package:

- If you have Ubuntu installed on your computer and want to search for a specific package and its current state. 

For example:
$ dpkg --install | grep ntp


or if you want to search a package by its version:
$ dpkg --install | grep ntp | grep 1:4


You can add more conditions by adding more “grep” commands.

## List Installed Packages with Apt

- apt is a command-line interface for the package management system. It was introduced in Ubuntu 14.04 and combines the most commonly used commands from apt-get and apt-cache including an option to list installed packages.

- To list the installed packages on your Ubuntu system use the following command:

$ sudo apt list --installed


- The packages list is long and it is a good idea to pipe the output to less to make it easier to read:

$ sudo apt list --installed | less

- To find out whether a specific package is installed you can filter the output with the grep command. 
For example: 

$ sudo apt list --installed | grep ntp


## List Installed Packages with dpkg-query 
$ sudo dpkg-query -l | less



- You can filter the dpkg-query -l output with grep same as the apt output:

$ sudo dpkg-query -l | grep package_name



## Create a list of all installed packages

- To create a list of the names of all installed packages on your Ubuntu or Debian system and save it in a file named packages_list.txt, run the following command:

$ sudo dpkg-query -f '${binary:Package}\n' -W > packages_list.txt




- Now that you have the list, if you want to install the same packages on your new server you can do that with:
$ sudo xargs -a packages_list.txt apt install

## Count the number of packages installed

- To find out how many packages are installed on your system you can use the same command as before but instead of redirecting the output to a file you can pipe it to the wc utility and count the lines:
$ sudo dpkg-query -f '${binary:Package}\n' -W | wc -l


Feel free to leave a comment if you have any questions.
Share on Google Plus

About howtoused

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment