dpkg

Overview

The dpkg (Debian Package) command is a low-level package manager for Debian-based systems. It directly handles .deb package operations without managing dependencies.

Syntax

dpkg [options] action

Common Actions

Action Description
-i Install package
-r Remove package
-P Purge package
-l List packages
-s Package status
-L List files
-S Search file owner
-C Check database
--configure Configure package
--unpack Unpack package
--verify Verify package
--audit Audit package

Common Options

Option Description
--force-all Force operations
--ignore-depends Ignore dependencies
--no-act Simulation mode
--root=dir Alternative root
--admindir=dir Alternative admin dir
--log=file Alternative log file
--status-fd n Send status to fd n
--print-architecture Show architecture

Key Use Cases

  1. Package installation
  2. Package removal
  3. Package queries
  4. System verification
  5. Package information

Examples with Explanations

Example 1: Install Package

dpkg -i package.deb

Install .deb package

Example 2: Remove Package

dpkg -r package_name

Remove package

Example 3: List Files

dpkg -L package_name

List package files

Common Usage Patterns

  1. Package status:

    dpkg -s package_name
  2. Find owner:

    dpkg -S /path/to/file
  3. List installed:

    dpkg -l | grep '^ii'

Security Considerations

  1. Package verification
  2. Root privileges
  3. System integrity
  4. Configuration files
  5. Dependencies

Additional Resources

Best Practices

  1. Verify packages
  2. Backup configuration
  3. Check dependencies
  4. Document changes
  5. Test installation

Package States

  1. Not installed
  2. Config-files
  3. Half-installed
  4. Unpacked
  5. Half-configured

Troubleshooting

  1. Broken packages
  2. Dependencies
  3. Configuration errors
  4. Space issues
  5. Database corruption