3 ways to list installed packages in ubuntu 20.04

Method 1 : list installed packages using command apt

apt list --installed
root@ubuntu:/home/j# apt list --installed | wc -l
 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
 1615
 root@ubuntu:/home/j#

We can see this host has 1615 packages installed

   list        list is somewhat similar to dpkg-query --list in that it can display a list of packages        satisfying certain criteria. It supports glob(7) patterns for matching package names as well as        options to list installed (--installed), upgradeable (--upgradeable) or all available        (--all-versions) versions.

Method 2: list installed packages using dpkg command

dpkg --get-selections

OR

dpkg -l

OR

dpkg-query  --list

Note: For dpkg-query –list and dpkg -l there are 5 lines additional information.

Method 3: list manually installed packages using command apt-mark

root@ubuntu:/home/j# apt-mark 
apt 2.0.2ubuntu0.2 (amd64)
Usage: apt-mark [options] {auto|manual} pkg1 [pkg2 ...]

apt-mark is a simple command line interface for marking packages
as manually or automatically installed. It can also be used to
manipulate the dpkg(1) selection states of packages, and to list
all packages with or without a certain marking.

Most used commands:
  auto - Mark the given packages as automatically installed
  manual - Mark the given packages as manually installed
  minimize-manual - Mark all dependencies of meta packages as automatically installed.
  hold - Mark a package as held back
  unhold - Unset a package set as held back
  showauto - Print the list of automatically installed packages
  showmanual - Print the list of manually installed packages
  showhold - Print the list of packages on hold
root@ubuntu:/home/j# apt-mark showmanual | wc -l
56
root@ubuntu:/home/j# apt-mark showauto | wc -l
1558

Leave a Reply

Your email address will not be published. Required fields are marked *