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
- Package installation
- Package removal
- Package queries
- System verification
- 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
Package status:
dpkg -s package_name
Find owner:
dpkg -S /path/to/file
List installed:
dpkg -l | grep '^ii'
Security Considerations
- Package verification
- Root privileges
- System integrity
- Configuration files
- Dependencies
Additional Resources
Best Practices
- Verify packages
- Backup configuration
- Check dependencies
- Document changes
- Test installation
Package States
- Not installed
- Config-files
- Half-installed
- Unpacked
- Half-configured
Troubleshooting
- Broken packages
- Dependencies
- Configuration errors
- Space issues
- Database corruption