Published on October 24, 2024By DeveloperBreeze

Essential dpkg Commands Cheat Sheet for Debian and Ubuntu Systems

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.

Comments

Please log in to leave a comment.

Continue Reading: