M BUZZ CRAZE NEWS
// news

How to list all my packages from command line which can show package name, license, source url, etc?

By Sarah Rodriguez

How to get all the installed package list with there license, source url? Such as following only shows name of the package only.

$ dpkg --get-selections
acpi-support install
acpid install
adduser install
adium-theme-ubuntu install
aisleriot install
alacarte install

For example in Fedora/CentOS (RED HAT LINUX BRANCH), you can see that:

$ yum info busybox
Loaded plugins: auto-update-debuginfo, langpacks, presto, refresh-packagekit
Available Packages
Name : busybox
Arch : i686
Epoch : 1
Version : 1.18.2
Release : 5.fc15
Size : 615 k
Repo : updates
Summary : Statically linked binary providing simplified versions of system commands
URL :
License : GPLv2
Description : Busybox is a single binary which includes versions of a large number : of system commands, including a shell. This package can be very : useful for recovering from certain types of system failures, : particularly those involving broken shared libraries.

Follow up:

/var/lib/apt/lists$ ls
extras.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages
extras.ubuntu.com_ubuntu_dists_natty_main_source_Sources
extras.ubuntu.com_ubuntu_dists_natty_Release
extras.ubuntu.com_ubuntu_dists_natty_Release.gpg
lock
partial
security.ubuntu.com_ubuntu_dists_natty-security_main_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_main_source_Sources
security.ubuntu.com_ubuntu_dists_natty-security_multiverse_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_multiverse_source_Sources
security.ubuntu.com_ubuntu_dists_natty-security_Release
security.ubuntu.com_ubuntu_dists_natty-security_Release.gpg
security.ubuntu.com_ubuntu_dists_natty-security_restricted_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_restricted_source_Sources
security.ubuntu.com_ubuntu_dists_natty-security_universe_binary-amd64_Packages
security.ubuntu.com_ubuntu_dists_natty-security_universe_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_main_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_multiverse_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_multiverse_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_Release
us.archive.ubuntu.com_ubuntu_dists_natty_Release.gpg
us.archive.ubuntu.com_ubuntu_dists_natty_restricted_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_restricted_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty_universe_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty_universe_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_main_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_main_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_multiverse_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_multiverse_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_Release
us.archive.ubuntu.com_ubuntu_dists_natty-updates_Release.gpg
us.archive.ubuntu.com_ubuntu_dists_natty-updates_restricted_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_restricted_source_Sources
us.archive.ubuntu.com_ubuntu_dists_natty-updates_universe_binary-amd64_Packages
us.archive.ubuntu.com_ubuntu_dists_natty-updates_universe_source_Sources

6 Answers

dpkg-query is a utility which allows you to query the dpkg database. To print the name and homepage of all installed packages:

$ dpkg-query -f='${PackageSpec;-30}\t${Homepage}\n' -W "*"
a2ps
aalib1
abrowser
abrowser-branding
accountsservice
acl
acpi-support
acpid
adbbs
adduser
...

Note that the homepage is not a required entry in the Debian package control file. I'd say only around 40% of the packages installed on my system have a homepage listed.

There is no simple way to (programatically) determine the license of a package. The Debian control file has no field for a license title. License details for a package foo should be given in the /usr/share/doc/<foo>/copyright file. However, there is no standard format for these files. Some of them are fairly simple and basically say this is released under the GPL v3, see /usr/share/common-licenses/GPL-3 for the full license text. Others have a custom license included in full. Complex packages can have different licenses for different pieces of it (e.g., one for the program and another for graphics). Often, the license of the Debian packaging information is also included.

In short: it is simple to manually get the license for a single package. If you need to do it automatically for all installed packages, it will take a large amount of effort.

10

Building off of @crysman's answer: This worked for many packages on ubuntu 14.04, and the ${packages:amd64} part was to navigate to the correct folder based on my processor.

for package in `dpkg -l | grep ^ii | awk '{print $2}'`; do echo -e $package"\t"`grep License /usr/share/doc/${package%:amd64}/copyright`; done > ~/dpkg.txt

The license and source url (I think you mean here the upstream source url of the tarball) can usually be found in a file called copyright. This file should be in every package, but it has only been recently "standardized" for easier machine/computer reading (see DEP5).

Not all packages have the licenses correctly filled in. Also, not all the packages have machine-readable copyright files. One single file can sometimes require a separate license and can make the debian package a candidate for removal if the license does not allow redistribution (or it's not a free/open source approved license).

In order to download the debian/copyright file of each package you could use the cupt package manager, like so:

cupt copyright busybox python > all-copyrights.txt

or to get one file per package:

for i in busybox python; do cupt copyright "$i" >"$i"_copyright.txt; done

In contrast to Fedora, Debian/Ubuntu normally doesn't give a single license for a package but instead lists all the licenses in the source; it's by far more accurate in that sense, but also harder to get an overview. Also, the non-uniform format of older debian/copyright files doesn't help either :)

The closest thing I can think of that is comparable to yum info would be apt-cache show. I don't know if ever will show the license, but it gives a bunch of details about a package. You can provide multiple package names to get details about more than one package at once.

For example:

matt@eden:~$ apt-cache show python
Package: python
Priority: important
Section: python
Installed-Size: 768
Maintainer: Ubuntu Developers <>
Original-Maintainer: Matthias Klose <>
Architecture: all
Source: python-defaults
Version: 2.7.2-7ubuntu2
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.2-3~), python-minimal (= 2.7.2-7ubuntu2)
Suggests: python-doc (= 2.7.2-7ubuntu2), python-tk (= 2.7.2-7ubuntu2)
Conflicts: python-central (<< 0.5.5)
Breaks: python-bz2 (<< 1.1-8), python-csv (<< 1.0-4), python-email (<< 2.5.5-3), update-manager (<= 0.200.5-1)
Filename: pool/main/p/python-defaults/python_2.7.2-7ubuntu2_all.deb
Size: 165792
MD5sum: a4b881e98e39f213bc8bbcfac566dd21
SHA1: 8a85fd4e62d1bad26a03ceef4313a12521e8a1dc
SHA256: ba95771b54aa4a1211486651fea1ecbac9e2dbbb4f66435e8a4dd0cb3e86bf4b
Description-en: interactive high-level object-oriented language (default version) Python, the high-level, interactive object oriented language, includes an extensive class library with lots of goodies for network programming, system administration, sounds and graphics. . This package is a dependency package, which depends on Debian's default Python version (currently v2.7).
Homepage:
Description-md5: d1ea97f755d8153fe116080f2352859b
Bugs:
Origin: Ubuntu
Supported: 18m
Task: minimal
1

You might use something like:

for package in `dpkg -l | grep ^ii | awk '{print $2}'`; do apt-cache policy $package; done | grep -iv "version table" | grep -i -e :$ -e multiverse -e restricted

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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