Posted: . At: 1:43 PM. This was 6 years ago. Post ID: 12047
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Some very useful apt tips for Debian and Ubuntu.


There are some very useful tricks that can be used to get information about packages installed on a Debian or Ubuntu machine. Here are just a few.

Get a graphical view of the actual dependencies of a package such as Firefox.

Firstly, install the graphviz package.

jason@Yog-Sothoth:~$ sudo apt install graphviz

Then use this command to get information about the dependencies of Firefox.

jason@Yog-Sothoth:~$ apt-cache -o APT::Cache::GivenOnly=1 dotty firefox | dot -T png > out.png

This is the result of this command.

Visual view of Firefox package dependencies.
Visual view of Firefox package dependencies.

Very cool huh?

Download a Debian apt package, but do not install it.

jason@Yog-Sothoth:~/dpkg$ apt download chromium-browser
Get:1 http://au.archive.ubuntu.com/ubuntu artful-security/universe amd64 chromium-browser amd64 65.0.3325.181-0ubuntu0.17.10.1 [51.8 MB]
Fetched 51.8 MB in 39s (1,325 kB/s)

This is easy. Then it can be unpacked. Just create a directory under the current working directory, in this case it is the out/ directory, then the apt package may be unpacked into it.

jason@Yog-Sothoth:~/dpkg$ mkdir out
jason@Yog-Sothoth:~/dpkg$ dpkg -x chromium-browser_65.0.3325.181-0ubuntu0.17.10.1_amd64.deb out/

How to repack an installed package into a Debian *.deb file. This simple command will create a Debian *.deb package from an installed one.

jason@Yog-Sothoth:~/dpkg$ dpkg-repack mc
dpkg-repack: warning: unknown information field 'Original-Maintainer' in input data in entry in dpkg's status file
dpkg-deb: building package 'mc' in './mc_4.8.19-1_amd64.deb'.

And it works very well.

jason@Yog-Sothoth:~/dpkg$ ls -hula
total 50M
drwxrwxr-x  3 jason jason 4.0K Apr 10 13:30 .
drwxr-xr-x 62 jason jason 4.0K Apr 10 13:13 ..
-rw-r--r--  1 jason jason  50M Apr 10 13:21 chromium-browser_65.0.3325.181-0ubuntu0.17.10.1_amd64.deb
-rw-r--r--  1 jason jason 464K Apr 10 13:30 mc_4.8.19-1_amd64.deb
drwxr-xr-x  4 jason jason 4.0K Apr 10 13:21 out

List information about a package in the repository.

jason@Yog-Sothoth:~/dpkg$ dpkg -l nmap
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                     Version                   Architecture              Description
+++-========================================-=========================-=========================-=====================================================================================
ii  nmap                                     7.60-1ubuntu1             amd64                     The Network Mapper

List all of the files that are created on your filesystem when the package is installed. This could be very useful information.

jason@Yog-Sothoth:~/dpkg$ dpkg -L bc
/.
/usr
/usr/bin
/usr/bin/bc
/usr/share
/usr/share/doc
/usr/share/doc/bc
/usr/share/doc/bc/AUTHORS
/usr/share/doc/bc/NEWS.gz
/usr/share/doc/bc/README
/usr/share/doc/bc/bc.html
/usr/share/doc/bc/changelog.Debian.gz
/usr/share/doc/bc/copyright
/usr/share/doc/bc/examples
/usr/share/doc/bc/examples/ckbook.b
/usr/share/doc/bc/examples/pi.b
/usr/share/doc/bc/examples/primes.b
/usr/share/doc/bc/examples/twins.b
/usr/share/doc-base
/usr/share/doc-base/bc
/usr/share/info
/usr/share/info/bc.info.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/bc.1.gz
/usr/share/menu
/usr/share/menu/bc

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.