Linuxips
  • Home
  • Linux
  • Debian
  • Ubuntu
  • Fedora
  • Arch Linux
No Result
View All Result
Linuxips
  • Home
  • Linux
  • Debian
  • Ubuntu
  • Fedora
  • Arch Linux
No Result
View All Result
Linuxips
No Result
View All Result
Home Commands

dpkg Command in Linux

admin by admin
August 17, 2022
Reading Time: 6 mins read
0
dpkg Command in Linux

This guide explores about dpkg Command in Linux. The dpkg command syntax and options. The dpkg in Linux is the primary package manager for Debian and Debian-based systems, such as Ubuntu. The tool installs, builds, removes, configures, and retrieves information for Debian packages. The command works with packages in .deb format.

Contents hide
1 Prerequisites
2 dpkg Command in Linux
2.1 dpkg Command Syntax
2.2 dpkg Command Options
3 Installing deb files with dpkg
4 List Known Packages
4.1 Remove Package
4.2 Purge Package
4.3 Show Package Contents
4.4 Check If the Package Installed
4.5 Show Package Information
4.6 List Installed Package Files’ Locations
4.7 Check dpkg Command Version
4.8 Print Help
5 Conclusion

Prerequisites

  • A system with a Debian or a Debian-based OS.
  • Access to the command line/terminal as sudo.
  • A .deb file to work with the examples.

dpkg Command in Linux

dpkg Command Syntax

The basic syntax for the dpkg command is:

$ dpkg [options] action

The command accepts one action and zero or more options.

The dpkg command acts as a front-end for the following two tools:

  1. The dpkg-deb command, which shows information about .deb packages.
  2. The dpkg-query command, which shows the information from the dpkg database.

The dpkg command runs actions from dpkg-query and dpkg-deb. Therefore, the following two commands show the same result:

$ dpkg -l
$ dpkg-query -l

The action -l is a dpkg-query action that lists all packages from the dpkg database. The dpkg command detects the foreign options and runs dpkg-query automatically.

dpkg Command Options

The table below provides brief descriptions of commonly used options and actions for the dpkg command.

command.

SyntaxTypeDescription
-i <package.deb>
--install <package.deb>
ActionInstalls the package.
--unpack <package.deb>ActionUnpacks the package without configuration.
--configure <package>ActionConfigures an unpacked package.
-r <package>
--remove <package>
ActionRemoves an installed package. Does not remove configuration files and other data.
-P <package>
--purge <package>
ActionPurges an installed or removed package. Deletes configuration files and other data.
--get-selectionsActionFetches packages with current selections.
--set-selectionsActionSets file selection states from a file read from standard input.
-b <directory>
--build <directory>
Action
(from dpkg-deb)
Builds a .deb package.
-c <package.deb>
--contents <package.deb>
Action
(from dpkg-deb)
Lists package contents.
-I <package.deb>
--info <package.deb>
Action
(from dpkg-deb)
Shows information about a package.
-l <pattern>
--list <pattern>
Action
(from dpkg-query)
Lists packages by matching the pattern.
-L <package>
--listfiles <package>
Action
(from dpkg-query)
List installed package’s file locations.
-s <package>
--status <package>
Action
(from dpkg-query)
Shows the status of an installed package.
-S <pattern>
--search <pattern>
Action
(from dpkg-query)
Search for a pattern in installed packages.
-R
--recursive
OptionHandles action recursively in target directory and subdirectories.
--log=<file>OptionLogs status change updates to a file.
--no-act
--dry-run
--simulate
OptionShows output without committing changes. Use before action.

Actions that change the system, such as package installation or removal, require sudo privileges. Information-based options do not require special user privileges.

Privileged access management helps secure the system by disallowing regular users to make system-wide changes.

Installing deb files with dpkg

dpkg is a low-level package manager for Debian-based systems. Use the -i (or –install) option to install deb packages with dpkg.

$ sudo dpkg -i code_1.70.1_amd64.deb
$ sudo dpkg -i code_1.70.1_amd64.deb 
[sudo] password for techdhee: 
Selecting previously unselected package code.
(Reading database ... 199013 files and directories currently installed.)
Preparing to unpack code_1.70.1_amd64.deb ...
Unpacking code (1.70.1-1660113095) ...
Setting up code (1.70.1-1660113095) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for shared-mime-info (2.1-2) ...


The command requires sudo to install a .deb package.

List Known Packages

To list all known packages, use the -l tag:

$ dpkg -l

The command prints the packages in pager mode. Navigate using the arrow keys or use space to list by page. Press q to exit the list. The columns list each package’s name, version, architecture, and description.

Remove Package

To remove a Debian package, use the following command:

$ dpkg -r <package>

Purge Package

To purge a package, use the -P option:

$ sudo dpkg -P <package>

Show Package Contents

A .deb package contains several files and directories, indicating where the package resides after installation or unpacking.

To display the package contents, run:

$ dpkg -c <package.deb>

Check If the Package Installed

To check whether a package is installed, use the -s tag:

$ dpkg -s <package>

Show Package Information

To show package information directly from the .deb file, use the following command:

$ dpkg -I <package.deb>

List Installed Package Files’ Locations

To list the package files and their location, use the -L tag:

$ dpkg -L <package>

Check dpkg Command Version

To check which dpkg version the system is running, use:

$ dpkg --version

The output shows the dpkg version along with the architecture.

Print Help

To show a simple help menu, use the following command:

$ dpkg --help

Use the man command to find find the complete documentation.

Conclusion

After following this tutorial and the examples from this tutorial, you should master the basics of the dpkg command. You can use it as you want. Enjoy!!!

Related Linux Tutorials:

  • How to Install Cisco Packet Tracer on Ubuntu.
  • How to install Tweak Tool on Ubuntu 21.04.
  • ZSH to BASH | How to Install ZSH on Ubuntu.
  • How to Install Ubuntu.
  • ls Command in Linux
ShareTweetSendShareShare
Previous Post

Nala – A Feature-rich Commandline For APT Package Manager

Next Post

How to Install Vscode on Ubuntu 22.04

admin

admin

Linuxips is a Linux blog that publishes articles and tutorials about server operations, installations, new techniques and Linux security.

Related Posts

Install ZSH on Arch Linux
Arch Linux

How to Install ZSH on Arch Linux

January 6, 2024
How To Use AppImage in Linux
Linux

How To Use AppImage in Linux [Complete Guide]

April 2, 2023
How To Install uGet Download Manager On Ubuntu
Linux

How To Install uGet Download Manager On Ubuntu

March 8, 2023
Linux Files and Directories
Linux

Linux Files and Directories

March 3, 2023
How to Create Files With Passwords in Linux
Linux

How to Create Files With Passwords in Linux

February 27, 2023
pwd Command in Linux
Commands

pwd command in Linux

November 6, 2022

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

You might also like

Install ZSH on Arch Linux

How to Install ZSH on Arch Linux

January 6, 2024
How to Install ZSH on Kali Linux 2024.1

How to Install ZSH on Kali Linux

January 5, 2024
How To Use AppImage in Linux

How To Use AppImage in Linux [Complete Guide]

April 2, 2023
How To Install uGet Download Manager On Ubuntu

How To Install uGet Download Manager On Ubuntu

March 8, 2023
How to Install ZSH on Ubuntu 22.10

How to Install ZSH on Ubuntu 22.10

March 7, 2023
Linux Files and Directories

Linux Files and Directories

March 3, 2023

© 2024 Linuxips.com - Linux Tips, Tricks and Tutorials.

  • Home
  • Web Stories
  • Privacy Policy
  • Contact Us
  • Disclaimer
No Result
View All Result
  • Home
  • Linux
  • Debian
  • Ubuntu
  • Fedora
  • Arch Linux

© 2024 Linuxips.com - Linux Tips, Tricks and Tutorials.