DeveloperBreeze

dpkg is a powerful command-line tool for managing software packages in Debian-based systems such as Debian and Ubuntu. This cheat sheet will guide you through some of the essential dpkg commands and concepts, including installing packages, updating package information, and working with dpkg’s database.


1. dpkg Overview:

  • What it is: A tool for installing, building, removing, and managing Debian packages.
  • Usage: Primarily used through the command line with different action parameters.
  • Primary Manager: The default package manager for Debian and Debian-based systems, including Ubuntu.

2. Basic dpkg Commands:

  • Install a package:
  sudo dpkg -i package_name.deb

Installs a .deb package.

  • Remove a package:
  sudo dpkg -r package_name

Removes an installed package while keeping its configuration files.

  • Purge a package:
  sudo dpkg --purge package_name

Completely removes the package, including its configuration files.

  • List installed packages:
  dpkg --list

Displays all installed packages.


3. Working with Multiple Packages:

  • Install multiple packages:
  sudo dpkg -i package1.deb package2.deb package3.deb

You can install multiple .deb packages in a single command by specifying the file names.


4. dpkg Database:

  • Location: The dpkg database is stored in /var/lib/dpkg.
  • Installed Packages: The status file within this directory contains information about all installed packages on your system.

5. Updating Package Information:

  • Check for updates:
  sudo dpkg --update-avail

Updates available packages by checking online repositories and downloads the latest versions to your local repository.


6. APT as a User-Friendly Front-End:

  • What it is: APT (Advanced Package Tool) is a higher-level front-end that interacts with dpkg and handles package relationships, dependencies, and versioning.
  • Why use APT: It simplifies the installation and removal of packages, ensuring that dependencies are correctly resolved.

Example for installing a package with APT:

  sudo apt install package_name

7. Access Complete Documentation:

  • To view detailed documentation and all possible commands for dpkg, use the manual page:
  man dpkg

Conclusion

dpkg is a crucial tool for managing software on Debian-based systems. With this cheat sheet, you can efficiently install, remove, and manage packages on your system. For a more user-friendly experience, APT serves as a front-end to handle complex tasks like dependency management, but understanding dpkg will give you more control over your system’s package management.

Continue Reading

Discover more amazing content handpicked just for you

Tutorial
python

Setting Up and Managing Python Virtual Environments Using venv

To install the dependencies listed in a requirements.txt file, run:

pip install -r requirements.txt

Aug 29, 2024
Read More
Tutorial
javascript nodejs

Crafting Beautiful CLI Tools with Node.js: Make Command-Line Interfaces Fun

This modular approach makes it easier to manage and expand your CLI tool as it grows in complexity.

To share your CLI tool with others, you’ll need to package it properly. Ensure that your package.json file has a bin field and all dependencies are listed.

Aug 20, 2024
Read More
Tutorial
bash

Creating and Managing a Linux Firewall with `iptables` and `firewalld`

   sudo iptables -L -v -n
  • Allow Incoming SSH Connections:

Aug 19, 2024
Read More
Tutorial
bash

Using Docker on Linux: From Installation to Deployment

   sudo yum install docker-ce
   sudo systemctl start docker

Aug 19, 2024
Read More
Tutorial
bash

Mastering Linux Package Management: APT, YUM, DNF, and More

sudo zypper install package-name

To refresh the repository list and update packages:

Aug 19, 2024
Read More
Tutorial
bash

Understanding and Managing Linux File Permissions

You can view the permissions of a file or directory using the ls -l command:

ls -l filename

Aug 19, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!