1

I have to extract the list of installed packages on Ubuntu/Debian without using command or without looking at dpkg.log?

The basic requirement is to get the list of installed packages on Debian/Ubuntu OS from the packages db file(if any) I'm able to get the list of available packages from following file,

/var/lib/dpkg/available

But this file contains all the packages including not installed.

Is there any other db file on Debian/Ubuntu which contains the list of only installed packages?

1

The file that contains the same information as that provided by the dpkg -l command is /var/lib/dpkg/status. From the FILES section of man dpkg:

   /var/lib/dpkg/status
          Statuses of available  packages.  This  file  contains  information
          about  whether  a package is marked for removing or not, whether it
          is installed or not, etc. See section  INFORMATION  ABOUT  PACKAGES
          for more info.

          The  status  file  is  backed  up  daily in /var/backups. It can be
          useful if it's lost or corrupted due to filesystems troubles.

   The format and contents of a binary package are described in deb(5).

But your "w/o command" requirement makes little sense since you will need to write a command to parse it. For example

awk -vRS= '/Status: install/ {print $2}' /var/lib/dpkg/status

will be roughly equivalent to dpkg -l | awk '$1 == "ii" {print $2}' (they will differ in sort order and some possible architecture suffixes like :amd64).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.