dpkg
stands for package manager for Debian. It is a major package management tool in Debian and Debian-based systems. It can be used to install, build, uninstall, and manage packages in thedeb
format.
When using the dpkg
command to install the software, you can use the -i
option and specify the path of the deb installation package. It is different from another package management tool apt-get
(Advanced Package Tool) under Ubuntu.
The apt-get
command does not directly manipulate the deb installation package file, but downloads and installs the software package from the software mirror source defined in the /etc/apt/sources.list
configuration file. You only need to specify the software when using it. Name (or version number can also be appended).
apt-get command to install the software:
$ apt-get install
The dpkg command installs the software:
$ dpkg -i
Therefore, dpkg is mainly used to install the deb software package that has been downloaded to the local, or to manage the installed software. And apt-get can download and install software directly from the remote software warehouse.
$ sudo apt-get install emacs
Reading package list...carry out
Analyzing the dependency tree of the package
Reading status information...carry out
The following software will be installed at the same time: emacs-bin-common emacs-common emacs-el emacs-gtk libm17n-0
libotf0 m17n-db
Recommended installation: mailutils emacs-common-non-dfsg m17n-docs gawk
The following [new] software packages will be installed: emacs emacs-bin-common emacs-common emacs-el emacs-gtk libm17n-0
libotf0 m17n-db
0 packages have been upgraded, 8 packages have been newly installed, and 0 packages have to be uninstalled. 115 packages have not been upgraded. Need to download 34.4
$ sudo dpkg -i fping_4.2-1_amd64.deb(Reading database...There are currently 252654 files and directories installed in the system.)
Ready to decompress fping_4.2-1_amd64.deb ...
Unpacking fping(4.2-1)And overwrite(4.2-1)...
Setting up fping(4.2-1)...
Processing for man-db(2.8.5-2)Trigger...
List installed software
You can use the dpkg -l
command to list the software installed in the current system and the status of the software package. Such as:
$ dpkg -l
Desired state=unknown(u)/installation(i)/delete(r)/Clear(p)/maintain(h)|status=未installation(n)/已installation(i)/Save configuration(c)/Unzip only(U)/Configuration failed(F)/不完全installation(H)/Trigger wait(W)/Trigger pending(T)|/error?=(no)/Reinstall(R)(Status, error: uppercase=malfunction)||/Name version architecture description
+++-=============================================-===================================-============-===============================================================================
ii 2048-qt 0.1.6-1build1 amd64 mathematics based puzzle game
ii accountsservice 0.6.50-0ubuntu1 amd64 query and manipulate user account information
ii acl 2.2.53-4 amd64 access control list - utilities
ii acpi-support 0.143 amd64 scripts for handling many ACPI events
ii acpid 1:2.0.31-1ubuntu2 amd64 Advanced Configuration and Power Interface event daemon
ii adduser 3.118ubuntu1 all add and remove users and groups
ii adwaita-icon-theme 3.32.0-1ubuntu1 all default icon theme ofGNOME(small subset)
ii alsa-base 1.0.25+dfsg-0ubuntu5 all ALSA driver configuration files
ii alsa-utils 1.1.8-1ubuntu1 amd64 Utilities for configuring and using ALSA
...
The first column ii
in the output of each line of this command indicates the installation and configuration status of the software package, and its format is as follows:
Expected State|Current State|Error
The expected state has the following
The current status is as follows:
There are several error states:
Therefore, ii
means that the software needs to be installed and has been installed without errors;
iu
means that the software has been installed but not configured correctly;
rc
means that the software has been deleted, but the configuration file has not been cleaned up.
View packages in the rc
state:
$ dpkg -l | grep ^rc
rc libmhash2:amd64 0.9.9.9-7 amd64 Library for cryptographic hashing and message authentication
rc linux-image-5.0.0-13-generic 5.0.0-13.14 amd64 Signed kernel image generic
rc linux-modules-5.0.0-13-generic 5.0.0-13.14 amd64 Linux kernel extra modules for version 5.0.0 on 64 bit x86 SMP
rc linux-modules-extra-5.0.0-13-generic 5.0.0-13.14 amd64 Linux kernel extra modules for version 5.0.0 on 64 bit x86 SMP
rc zabbix-proxy-mysql 1:4.0.4+dfsg-1 amd64 network monitoring solution -proxy(using MySQL)
In addition, you can use the dpkg -l
command to filter out packages whose names contain the specified pattern.
$ dpkg -l "nginx*"
Desired state=unknown(u)/installation(i)/delete(r)/Clear(p)/maintain(h)|status=未installation(n)/已installation(i)/Save configuration(c)/Unzip only(U)/Configuration failed(F)/不完全installation(H)/Trigger wait(W)/Trigger pending(T)|/error?=(no)/Reinstall(R)(Status, error: uppercase=malfunction)||/Name version architecture description
+++-==============-===============-============-=========================================================
ii nginx 1.15.9-0ubuntu1 all small, powerful, scalable web/proxy server
ii nginx-common 1.15.9-0ubuntu1 all small, powerful, scalable web/proxy server - common files
ii nginx-core 1.15.9-0ubuntu1 amd64 nginx web/proxy server(standard version)
un nginx-doc <no><no>(no描述)
un nginx-extras <no><no>(no描述)
un nginx-full <no><no>(no描述)
un nginx-light <no><no>(no描述)
Uninstall software
The
-r option of the dpkg
command can be used to uninstall the installed software package. In this case, you only need to specify the name of the software.
$ sudo dpkg -r vim(Reading database...There are currently 252653 files and directories installed in the system.)
Uninstalling vim(2:8.1.0320-1ubuntu3.1)...
update-alternatives:use/usr/bin/vim.tiny to provide in automatic mode/usr/bin/vi(vi)
update-alternatives:use/usr/bin/vim.tiny to provide in automatic mode/usr/bin/view(view)
update-alternatives:use/usr/bin/vim.tiny to provide in automatic mode/usr/bin/ex(ex)
update-alternatives:use/usr/bin/vim.tiny to provide in automatic mode/usr/bin/rview(rview)
have to be aware of is,-The r option will only remove the specified package without affecting its configuration file.
dpkg -c <package_file_path>
$ dpkg -c fping_4.2-1_amd64.deb
drwxr-xr-x root/root 0 2019-02-20 06:27 ./
drwxr-xr-x root/root 02019-02-2006:27./usr/
drwxr-xr-x root/root 02019-02-2006:27./usr/bin/-rwxr-xr-x root/root 521282019-02-2006:27./usr/bin/fping
drwxr-xr-x root/root 02019-02-2006:27./usr/share/
drwxr-xr-x root/root 02019-02-2006:27./usr/share/bug/-rwxr-xr-x root/root 1182017-06-1905:19./usr/share/bug/fping
drwxr-xr-x root/root 02019-02-2006:27./usr/share/doc/
drwxr-xr-x root/root 02019-02-2006:27./usr/share/doc/fping/-rw-r--r-- root/root 4952017-09-0608:00./usr/share/doc/fping/NEWS.Debian.gz
- rw-r--r-- root/root 16152019-02-2006:27./usr/share/doc/fping/changelog.Debian.gz
- rw-r--r-- root/root 34452017-12-0704:09./usr/share/doc/fping/copyright
drwxr-xr-x root/root 02019-02-2006:27./usr/share/lintian/
drwxr-xr-x root/root 02019-02-2006:27./usr/share/lintian/overrides/-rw-r--r-- root/root 412017-06-1905:19./usr/share/lintian/overrides/fping
drwxr-xr-x root/root 02019-02-2006:27./usr/share/man/
drwxr-xr-x root/root 02019-02-2006:27./usr/share/man/man8/-rw-r--r-- root/root 57332019-02-2006:27./usr/share/man/man8/fping.8.gz
- rw-r--r-- root/root 15122019-02-2006:27./usr/share/man/man8/fping6.8.gz
lrwxrwxrwx root/root 02019-02-2006:27./usr/bin/fping6 -> fping
View the details of the package (installed)
dpkg -s <package>Or dpkg--status <package>
$ dpkg -s fping
Package: fping
Status: deinstall ok installed
Priority: optional
Section: net
Installed-Size:87
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Version:4.2-1
Depends: libcap2-bin, netbase,libc6(>=2.15)
Enhances:netdata(>=1.5)
Description: sends ICMP ECHO_REQUEST packets to network hosts
fping is a ping like program which uses the Internet Control Message Protocol(ICMP) echo request to determine if a target host is responding. fping
differs from ping in that you can specify any number of targets on the command
line, or specify a file containing the lists of targets to ping. Instead of
sending to one target until it times out or replies, fping will send out a
ping packet and move on to the next target in a round-robin fashion.
Original-Maintainer: Axel Beckert <[email protected]>
Homepage: https://www.fping.org/
dpkg -L <package>Or dpkg--list-files <package>
$ dpkg -L fping
/./usr
/usr/bin
/usr/bin/fping
/usr/share
/usr/share/bug
/usr/share/bug/fping
/usr/share/doc
/usr/share/doc/fping
/usr/share/doc/fping/NEWS.Debian.gz
/usr/share/doc/fping/changelog.Debian.gz
/usr/share/doc/fping/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/fping
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/fping.8.gz
/usr/share/man/man8/fping6.8.gz
/usr/bin/fping6
dpkg -S <filename_pattern>Or dpkg--search <filename_pattern>
$ dpkg -S sites-available
apache2:/etc/apache2/sites-available/default-ssl.conf
apache2:/etc/apache2/sites-available/000-default.conf
nginx-common:/etc/nginx/sites-available
nginx-common:/etc/nginx/sites-available/default
apache2:/etc/apache2/sites-available
Recommended Posts