Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
Debian Software Package Management(dpkg) in Linux
Next article icon

Debian Software Package Management(dpkg) in Linux

Last Updated : 10 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In Linux, there are a lot of different distributions and each of these distributions has a different package type.  For example .rpm or Red hat Package Manager is used as the package in the Linux distribution. A package is the compressed version of the software.

In this article, we will go through the Debian package which is used by Ubuntu. D package or Debian Package is used to install and download the software in Debian based Linux systems. Debian files end with .deb extension.

Table of Content

  • What is dpkg in Linux?
    • Basic Syntax
    • Common Actions of dpkg
    • Example
  • dpkg commands in Linux with Examples
  • Linux dpkg - FAQs

What is dpkg in Linux?

`dpkg` (Debian Package) is a low-level package management system for Debian-based Linux distributions, such as Ubuntu. It handles the installation, configuration, upgrade, and removal of software packages. Unlike higher-level tools like `apt`, which resolve dependencies and download packages from repositories, `dpkg` directly manages individual `.deb` files, making it essential for managing local packages and performing detailed package operations.

Basic Syntax

dpkg [options] action

Here,

options - optional tags that modify the behavior of dpkg
action - specifies what dpkg should do

Common Actions of dpkg

The following are the common actions of dpkg:

Option

Behavior of option

-i or --install

to install a package

-r or --remove

to remove a package

-p or --pure

to remove a package with long its dependencies.

-s or --status

It shows the status of a package.

Example

  • The following command is used to install a page from .deb files:
sudo dpkg -i package_name.deb

dpkg commands in Linux with Examples

1. Installing a stand-alone package using the Debian package

  • To install a package -i flag is used. To download a stand-alone package using the Debian package, this command is used:
sudo dpkg -i name_of_package.deb

Example: To download standalone package for the open-source text editor, atom

sudo dpkg -i atom-amd64.deb
Installing a stand-alone package using the Debian package

2. Removing a package using the Debian package

  • To remove a package -r flag is used 
sudo dpkg -r name_of_package

Example: To remove the package for the text editor "atom"

sudo dpkg -r atom
removing package using debian package manager

Note: -P flag helps to remove everything including conf files.

dpkg -P [package-name]
dpkg -P googler_3.3.0-1_all.deb

3. Listing the debian packages

  • To list all the Debian packages -l flag is used.
dpkg -l
  • The above line would give the output similar to the one shown below:
Listing debain packages
  • To find a particular package use the grep command: 
dpkg -l | grep name_of_package.
  • The output of this command would look similar to the one shown below:
Searching for debian packages

4. List the dpkg commands available

  • -help option lists all the available dpkg commands
dpkg –help
  • Output of this command would look similar to the one shown below:
Listing the dpkg commands
  • The following are the a few more options of dpkg:
dpkg options

5. View the content of a particular package

  • To view the content of the particular package -c flag is used
dpkg -c [name of the package]
dpkg -c flashplugin-nonfree_3.2_i386.deb
  • Output of this command would look similar to the one shown below:
viewing the content of paticular package

6. Print architecture of dpkg installs

  • --print-architecture command prints the architecture of dpkg installs
dpkg --print-architecture
  • Output could be amd64, i386, etc.
  • For example, the output produced by the above code is as shown:
print architecture of dpkg installations

7. Unpack a package

  • --unpack flag helps us unpack the package.
dpkg --unpack [package-name]
dpkg --unpack flashplugin-nonfree_3.2_i386.deb
  • The output would look as shown below:
Unpacking the packages
  • The package can be later configured using --configure flag.
dpkg --configure [package-name]
dpkg --configure flashplugin-nonfree
setting up flashplugin

8. Check if the package is installed or not

  • To check if a particular package is installed or not -s flag is used.
dpkg -s [package-name]
dpkg -s git
  • The output would look as shown below:
checking whether package is installed or not

9. Reconfigure the installed package

  • To reconfigure the already installed package dpkg-reconfigure command is used
dpkg-reconfigure [package-name]

Locate the installed package

  • The location of the installed package can be found using -L flag.
dpkg -L [package-name]
dpkg -L git
  • The output would look as shown below:
locating the installed packages

10. Check for any issue with the installed package

  • --audit flag would be used to check for the issues with the package.
dpkg --audit

11. Erase information 

  • –clear-avail Erases available information about the current packages
dpkg –-clear-avail

12. Display dpkg version

  • dpkg –version is used to display dpkg version information.
sudo dpkg --version
checking version of dpkg

Next Article
Debian Software Package Management(dpkg) in Linux

P

prernaajitgupta
Improve
Article Tags :
  • Linux-Unix
  • linux

Similar Reads

    How to Manage Debian Packages in Linux?
    Debian, one of the oldest and most respected Linux distributions, is renowned for its stability, security, and robust package management system. Managing Debian packages effectively is crucial for maintaining a healthy and well-functioning Linux system. In this comprehensive guide, we will explore e
    9 min read
    YUM Commands for Linux Package Management
    If you are a Linux user or system administrator, chances are you've come across YUM (Yellowdog Updater, Modified) at some point in your journey. YUM is a powerful package management tool that simplifies the process of installing, updating, and managing software on Red Hat-based Linux distributions l
    5 min read
    How to Use Package Managers in Linux? APT and YUM
    Package managers like APT and YUM are essential tools for managing software on Linux systems. They allow you to install, update, and remove packages easily, ensuring your system is up-to-date and secure. APT is commonly used in Debian-based distributions like Ubuntu, while YUM is used in Red Hat-bas
    5 min read
    How to Manage Packages in Red Hat-based Linux?
    Package management tools like dnf (Dandified YUM) or yum (Yellowdog Updater Modified) are used to manage packages on Red Hat-based Linux systems. These programs support the installation, removal, and upgrading of software packages on your computer. Typical package management tasks include the follow
    4 min read
    How to Install a New Package Manager in Linux
    Linux offers several package managers for software installation, updates, and maintenance. In Linux, every distribution comes with a package manager by default. The Debian distribution comes with APT(Advanced Package Tool), Red Hat, and its derivatives such as CentOS and Fedora use YUM package manag
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences