Ubuntu – How to list all the packages from command line which can show package name, license, source url, etc

package-management

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         : http://www.busybox.net
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

Best Answer

  • 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                 http://cgit.freedesktop.org/accountsservice/
    acl                             http://savannah.nongnu.org/projects/acl/
    acpi-support                    
    acpid                           http://www.tedfelix.com/linux/acpid-netlink.html
    adbbs                           
    adduser                         http://alioth.debian.org/projects/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.