Home php教程 PHP开发 Use the dpkg command to manage software packages in Debian Linux systems

Use the dpkg command to manage software packages in Debian Linux systems

Nov 16, 2016 am 09:19 AM

dpkg means Debian Package Manager. dpkg is a command line tool that can install, build, remove and manage Debian software packages. dpkg uses Aptitude (preferred and more user-friendly) as the front-end interface that performs all operations.

Some other tools such as dpkg-deb and dpkg-query also use dpkg as a front-end to perform certain operations.

Most system administrators now use tools such as Apt, Apt-Get and Aptitude to easily manage software without having to worry.

However, you still need to use dpkg to install certain software when necessary. Some other package management tools widely used on Linux systems include yum, dnf, apt-get, rpm, Zypper, pacman, urpmi, etc.

Now, I’m going to explain the most commonly used dpkg commands with some examples on a machine with Ubuntu 15.10.

1) The syntax of common dpkg commands and the location of dpkg files

The following is the syntax of common dpkg commands and the location of dpkg related files. If you want to learn more about it, these will definitely be of great benefit to you.

1

2

3

4

5

6

7

8

9

### dpkg 命令的语法

$ dpkg -[command] [.deb package name]

$ dpkg -[command] [package name]

### dpkg 相关文件的位置

$ /var/lib/dpkg

### 这个文件包含了被 dpkg 命令(install、remove 等)所修改的包的信息

$ /var/lib/dpkg/status

### 这个文件包含了可用包的列表

$ /var/lib/dpkg/status

Copy after login

2) Install/upgrade software

In Debian-based systems, such as Debian, Mint, Ubuntu and elementryOS, use the following commands to install/upgrade the .deb software package. Here I am going to use the atom-amd64.deb file to install Atom. If Atom is already installed, it will be upgraded. Or a new Atom will be installed.

1

2

3

4

5

6

7

8

9

10

11

12

### 安装或升级 dpkg 软件包

$ sudo dpkg -i atom-amd64.deb

Selecting previously unselected package atom.

(Reading database ... 426102 files and directories currently installed.)

Preparing to unpack atom-amd64.deb ...

Unpacking atom (1.5.3) over (1.5.3) ...

Setting up atom (1.5.3) ...

Processing triggers for gnome-menus (3.13.3-6ubuntu1) ...

Processing triggers for bamfdaemon (0.5.2~bzr0+15.10.20150627.1-0ubuntu1) ...

Rebuilding /usr/share/applications/bamf-2.index...

Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...

Processing triggers for mime-support (3.58ubuntu1) ...

Copy after login

3) Install software from folder

In Debian-based systems, use the following commands to install software one by one from the directory. This will install all software with a .deb extension in the /opt/software directory.

1

2

3

4

5

6

7

8

9

10

11

$ sudo dpkg -iR /opt/software

Selecting previously unselected package atom.

(Reading database ... 423303 files and directories currently installed.)

Preparing to unpack /opt/software/atom-amd64.deb ...

Unpacking atom (1.5.3) ...

Setting up atom (1.5.3) ...

Processing triggers for gnome-menus (3.13.3-6ubuntu1) ...

Processing triggers for bamfdaemon (0.5.2~bzr0+15.10.20150627.1-0ubuntu1) ...

Rebuilding /usr/share/applications/bamf-2.index...

Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...

Processing triggers for mime-support (3.58ubuntu1) ...

Copy after login

4) Display the list of installed software

The following command can list all installed software in Debian system, and also display the software version and description information.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

$ dpkg -l

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  account-plugin-aim          3.12.10-0ubuntu2                   amd64        Messaging account plugin for AIM

ii  account-plugin-facebook     0.12+15.10.20150723-0ubuntu1       all          GNOME Control Center account plugin for single signon - facebook

ii  account-plugin-flickr       0.12+15.10.20150723-0ubuntu1       all          GNOME Control Center account plugin for single signon - flickr

ii  account-plugin-google       0.12+15.10.20150723-0ubuntu1       all          GNOME Control Center account plugin for single signon

ii  account-plugin-jabber       3.12.10-0ubuntu2                   amd64        Messaging account plugin for Jabber/XMPP

ii  account-plugin-salut        3.12.10-0ubuntu2                   amd64        Messaging account plugin for Local XMPP (Salut)

.

.

Copy after login

5) View the specified installed software

Use the following command to list the specified installed software, and the software version and description information will be displayed.

1

2

3

4

5

6

7

$ dpkg -l atom

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  atom       1.5.3     amd64               A hackable text editor for the 21st Century.

Copy after login

6) View the software installation directory

The following command can view the software installation path on Debian-based systems.

1

2

3

4

5

6

7

8

9

10

11

12

$ dpkg -L atom

/.

/usr

/usr/bin

/usr/bin/atom

/usr/share

/usr/share/lintian

/usr/share/lintian/overrides

/usr/share/lintian/overrides/atom

/usr/share/pixmaps

/usr/share/pixmaps/atom.png

/usr/share/doc

Copy after login

7) View the deb package contents

The following command can view the deb package contents. It will display a list of files in the .deb package.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

$ dpkg -c atom-amd64.deb

drwxr-xr-x root/root         0 2016-02-13 02:13 ./

drwxr-xr-x root/root         0 2016-02-13 02:13 ./usr/

drwxr-xr-x root/root         0 2016-02-13 02:13 ./usr/bin/

-rwxr-xr-x root/root      3067 2016-02-13 02:13 ./usr/bin/atom

drwxr-xr-x root/root         0 2016-02-13 02:13 ./usr/share/

drwxr-xr-x root/root         0 2016-02-13 02:13 ./usr/share/lintian/

drwxr-xr-x root/root         0 2016-02-13 02:13 ./usr/share/lintian/overrides/

-rw-r--r-- root/root       299 2016-02-13 02:13 ./usr/share/lintian/overrides/atom

drwxr-xr-x root/root         0 2016-02-13 02:13 ./usr/share/pixmaps/

-rw-r--r-- root/root    643183 2016-02-13 02:13 ./usr/share/pixmaps/atom.png

drwxr-xr-x root/root         0 2016-02-13 02:13 ./usr/share/doc/

.

.

Copy after login

8) Display detailed information of software

The following command can display detailed information of software, such as software name, software category, version, maintainer, software architecture, dependent software, software description, etc.

1

2

3

4

5

6

7

8

9

10

11

12

13

$ dpkg -s atom

Package: atom

Status: install ok installed

Priority: optional

Section: devel

Installed-Size: 213496

Maintainer: GitHub <atom@github.com>Architecture: amd64

Version: 1.5.3

Depends: git, gconf2, gconf-service, libgtk2.0-0, libudev0 | libudev1, libgcrypt11 | libgcrypt20, libnotify4, libxtst6, libnss3, python, gvfs-bin, xdg-utils, libcap2

Recommends: lsb-release

Suggests: libgnome-keyring0, gir1.2-gnomekeyring-1.0

Description: A hackable text editor for the 21st Century.

 Atom is a free and open source text editor that is modern, approachable, and hackable to the core.</atom@github.com>

Copy after login

9) Check which software the file belongs to

Use the following command to check which software the file belongs to.

1

2

$ dpkg -S /usr/bin/atom

atom: /usr/bin/atom

Copy after login

10) Remove/Delete Software

The following command can be used to remove/delete an installed software, but does not delete the configuration file.

1

2

3

4

5

6

7

8

$ sudo dpkg -r atom

(Reading database ... 426404 files and directories currently installed.)

Removing atom (1.5.3) ...

Processing triggers for gnome-menus (3.13.3-6ubuntu1) ...

Processing triggers for bamfdaemon (0.5.2~bzr0+15.10.20150627.1-0ubuntu1) ...

Rebuilding /usr/share/applications/bamf-2.index...

Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...

Processing triggers for mime-support (3.58ubuntu1) ...

Copy after login

11) Cleaning software

The following command can be used to remove/delete all files including configuration files.

1

2

3

4

5

6

7

8

$ sudo dpkg -P atom

(Reading database ... 426404 files and directories currently installed.)

Removing atom (1.5.3) ...

Processing triggers for gnome-menus (3.13.3-6ubuntu1) ...

Processing triggers for bamfdaemon (0.5.2~bzr0+15.10.20150627.1-0ubuntu1) ...

Rebuilding /usr/share/applications/bamf-2.index...

Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...

Processing triggers for mime-support (3.58ubuntu1) ...

Copy after login

12) Learn more

Use the following command to view more information about dpkg.

1

2

3

$ dpkg -help

$ man dpkg

Copy after login

Start experiencing dpkg.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)