Dependencies

Understanding software dependencies, dependency resolution, and troubleshooting broken or missing dependencies

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

1
2
3
4
5
apt-cache depends firefox
firefox
  Depends: libc6
  Depends: libgtk-3-0
  Depends: libx11-6

Shows what firefox needs to run

Example 2: Find What Depends on Package

1
2
3
4
5
6
apt-cache rdepends libssl1.1
libssl1.1
Reverse Depends:
  openssh-server
  apache2
  mysql-server

Shows packages that need libssl1.1

Example 3: Fix Broken Dependencies

1
sudo apt --fix-broken install

Attempts to resolve dependency conflicts

Example 4: Check Library Dependencies

1
2
3
ldd /usr/bin/ls
linux-vdso.so.1 => (0x00007fff8d1fe000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6

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

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 ldd to 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 autoremove regularly 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