Dependencies in Linux refer to software packages, libraries, or files that other programs require to function properly. Understanding dependency management is crucial for system administration, software installation, and troubleshooting package conflicts.
Key Concepts
- Package Dependencies: Software requirements needed for installation
- Library Dependencies: Shared libraries (.so files) programs need
- Dependency Resolution: Automatic handling of requirements
- Circular Dependencies: When packages depend on each other
- Broken Dependencies: Missing or incompatible requirements
Package Manager Commands
APT (Debian/Ubuntu)
apt install package-name
apt-cache depends package-name
apt-cache rdepends package-name
YUM/DNF (Red Hat/Fedora)
yum install package-name
yum deplist package-name
dnf repoquery --requires package-name
Common Dependency Commands
APT System
apt-cache depends - Show package dependencies
apt-cache rdepends - Show reverse dependencies
apt --fix-broken install - Fix broken dependencies
apt autoremove - Remove unused dependencies
YUM/DNF System
yum deplist - List package dependencies
yum history - View installation history
dnf repoquery --whatrequires - Find what needs package
Practical Examples
Example 1: Check Package Dependencies
|
|
Shows what firefox needs to run
Example 2: Find What Depends on Package
|
|
Shows packages that need libssl1.1
Example 3: Fix Broken Dependencies
|
|
Attempts to resolve dependency conflicts
Example 4: Check Library Dependencies
|
|
Shows shared libraries a binary needs
Use Cases
- Installing software packages safely
- Troubleshooting application startup issues
- Planning system upgrades
- Creating custom software distributions
- Resolving package conflicts
- System cleanup and optimization
Related Commands
ldd - Show shared library dependencies
dpkg -l - List installed packages (Debian)
rpm -qa - List installed packages (Red Hat)
ldconfig - Configure library cache
pkg-config - Retrieve compilation flags
Library Dependency Tools
objdump -p binary - Show binary dependencies
readelf -d binary - Display dynamic section
nm -D library.so - List dynamic symbols
Tips & Troubleshooting
Common Issues
- Missing libraries: Use
lddto identify, install dev packages - Version conflicts: Check with
apt list --installed - Broken packages: Run
apt --fix-broken install - Circular deps: May need manual intervention
Best Practices
- Always check dependencies before major upgrades
- Use virtual environments for development
- Keep package manager databases updated
- Document custom installations
- Test dependency changes in staging first
Performance Notes
- Too many dependencies slow system startup
- Use
apt autoremoveregularly to clean unused packages - Consider static linking for critical applications
- Monitor disk space usage from dependencies
Security Considerations
- Keep all dependencies updated for security patches
- Audit dependency chains for vulnerabilities
- Use official repositories when possible
- Verify package signatures before installation