🖥️dpkg
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dpkg command with important options and switches using examples.
5 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██████╗ ██╗ ██╗ ██████╗
# ██╔══██╗██╔══██╗██║ ██╔╝██╔════╝
# ██║ ██║██████╔╝█████╔╝ ██║ ███╗
# ██║ ██║██╔═══╝ ██╔═██╗ ██║ ██║
# ██████╔╝██║ ██║ ██╗╚██████╔╝
# ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝
# Install the package or upgrade it
dpkg -i test.deb
# Remove a package including configuration files
dpkg -P test.deb
# List all installed packages with versions and details
dpkg -I
# Find out if a Debian package is installed or not
dpkg -s test.deb | grep Status
#==============================#
# CMD dpkg Packetverwaltung
#==============================##==============================#
dpkg -l '*linux*' | grep '^ii'
# Get a list of debian packages with linux in their name and only list the ones that are fully installed.
dpkg -l '*3.19.0-2[56]*' | cat
# List packages with specific version and make sure the name column is visible by piping the output into cat.
dpkg -L packagename
# Matching files and packages in Debian/Ubuntu - To find out what files a package generated during installation.
dpkg -S /path/to/file
# We can also check the other way and find out what package a file belongs to
dpkg -S ls
# For the second command we need to use the full path as 'dpkg -S' just matches the string you supply it, so dpkg -S ls matches any package that has a file with 'ls' anywhere in the filename.
dpkg -S $( which notify-send )
# Find which Debian package the notify-send program is included with -> libnotify-bin
dpkg -l '*4.10.0*' | cat
# Sometimes in cases where columns are truncated, you can make them visible by passing output through cat.
# To organize the list in pages and columns ready for printing, issue the following command.
dpkg -l | pr --columns 3 -l 20
2017-01-06 13:19 Page 1
Desired=Unknown/Install ii adduser ii apg
| Status=Not/Inst/Conf- ii adwaita-icon-theme ii app-install-data
|/ Err?=(none)/Reinst-r ii adwaita-icon-theme- ii apparmor
||/ Name ii alsa-base ii apt
+++-=================== ii alsa-utils ii apt-clone
ii accountsservice ii anacron ii apt-transport-https
ii acl ii apache2 ii apt-utils
ii acpi-support ii apache2-bin ii apt-xapian-index
ii acpid ii apache2-data ii aptdaemon
ii add-apt-key ii apache2-utils ii aptdaemon-data
2017-01-06 13:19 Page 2
ii aptitude ii avahi-daemon ii bind9-host
ii aptitude-common ii avahi-utils ii binfmt-support
ii apturl ii aview ii binutils
ii apturl-common ii banshee ii bison
ii archdetect-deb ii baobab ii blt
ii aspell ii base-files ii blueberry
ii aspell-en ii base-passwd ii bluetooth
ii at-spi2-core ii bash ii bluez
ii attr ii bash-completion ii bluez-cups
ii avahi-autoipd ii bc ii bluez-obexd
.....
# Install profiling versions of all libghc dpkg packages
dpkg -l | grep libghc | grep "\-dev" | cut -d " " -f 3 | tr '\n' ' ' | sed -e 's/\-dev/\-prof/g' | xargs sudo apt-get install --yes
# Explanation:
# dpkg -l lists all installed system packages.
# grep libghc filters out all haskell packages
# grep "\-dev" filters out the actual source packages, where -dev can be replaced with -prof to get the name of the profiling package
# cut -d " " -f 3 converts lines from ii libghc-packagename-dev 0.1.3.3-7 amd64 description to libghc-packagename-dev
# tr '\n' ' ' Replaces newlines with spaces, merging it all into one line
# sed -e 's/\-dev/\-prof/g' Replaces -dev with -prof
# xargs sudo apt-get install --yes Passes the string (now looking like libghc-a-prof libghc-b-prof libghc-c-prof) as arguments to sudo apt-get install --yes which installs all package names it receives as arguments, and does not ask for confirmation.
# Limitations: Only works with apt (standard in ubuntu)
# List packages manually installed with process currently running - Sometimes we install programs, we forget about them, and they stay there wasting RAM. This one-liner try to find them.
ps -eo cmd | awk '{print $1}'| sort -u | grep "^/" | xargs dpkg -S 2>/dev/null | awk -F: '{print $1}' | sort -u | xargs apt-mark showmanual
# Sample output
# atom
# virtualbox
# bluez
# mosquitto
# teamviewer
# List the binaries installed by a Debian package - GNU grep's perl-compatible regular expression(PCRE).
function dpkgbinaries () { dpkg -L "$1" | grep -Po '.*/bin/\K.*'; }
# List the binaries installed by a Debian package - This shell function displays a list of binaries contained in an installed package; works on Debian based Linux distributions.
function dpgk-binaries () { for f in $(dpkg -L "$1" | grep "/bin/"); do basename "$f"; done; }
# Sample output
# $ binaries findutils
# find
# xargs
# List all ubuntu installed packages in a single line - Use xargs command to make one line.
dpkg --get-selections | grep -Evw 'deinstall$' | cut -f1 | sort -u | xargs
# List all ubuntu installed packages in a single line - This command lists all currently installed packages in ubuntu in a single line, for example to use later with apt install.
dpkg --get-selections | grep -v deinstall | sort -u | cut -f 1 | tr '\r\n' ' ' | sed '$s/ $/\n/'
# Sample output
# accountsservice acl acpid acpi-support adduser adwaita-icon-theme aisleriot alsa-base alsa-utils amd64-microcode anacron apg apparmor app-install-data-partner apport-gtk apport apport-symptoms appstream apt-clone apt-config-icons aptdaemon-data aptdaemon apt apturl-common apturl ... xserver-xorg-video-vesa xserver-xorg-video-vmware xul-ext-ubufox xwayland xxd xz-utils yaru-theme-gnome-shell yaru-theme-gtk yaru-theme-icon yaru-theme-sound yelp yelp-xsl zenity-common zenity zerofree zip zlib1g:amd64
#==============================##==============================#
# CMD dpkg #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command dpkg in a clear format. This allows users to quickly access the needed information for dpkg without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for dpkg are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.