Check Shared Library Dependencies with ldd and ldconfig
Check Shared Library Dependencies with ldd and ldconfig
Need to check system library dependencies on your Linux server? Want to monitor library dependencies, verify library availability, and detect missing libraries? This guide shows you how to check library dependencies using built-in commands and automated monitoring with Zuzia.app.
For comprehensive system monitoring strategies, see Server Performance Monitoring. For troubleshooting dependency issues, see System Updates Breaking Services.
Why Checking Library Dependencies Matters
System libraries provide shared functionality for applications. When library dependencies are missing or incompatible, applications can fail to start, services can crash, and system functionality can be compromised. Checking library dependencies helps you verify libraries are available, detect missing dependencies, track library versions, and maintain system stability.
Method 1: Check Library Dependencies
Check library dependencies to verify libraries are available:
View Library Dependencies
# Check library dependencies for binary
ldd /usr/bin/application
# View missing libraries
ldd /usr/bin/application | grep "not found"
# Check library dependencies for process
ldd /proc/PID/exe
# View all library dependencies
ldd /usr/bin/* | grep "not found"
Verify Library Availability
# Check if library exists
test -f /usr/lib/libssl.so && echo "Library exists" || echo "Library missing"
# View library search paths
ldconfig -p
# Check library versions
ldconfig -p | grep libssl
# Verify library compatibility
ldd /usr/bin/application | grep -v "not found"
Method 2: Detect Missing Libraries
Detect missing libraries to identify dependency issues:
Identify Missing Dependencies
# Find binaries with missing libraries
for binary in /usr/bin/*; do
ldd "$binary" 2>/dev/null | grep "not found" && echo "$binary: Missing libraries"
done
# Check for missing shared libraries
ldd /usr/bin/application | grep "not found"
# View library dependency errors
ldconfig -p 2>&1 | grep -i "error\|fail"
# Check library loading issues
dmesg | grep -i "library\|shared object"
Monitor Library Status
# Check library cache
ldconfig -p | wc -l
# View library cache status
ldconfig -v 2>&1 | tail -20
# Check for library conflicts
ldconfig -p | grep libssl | wc -l
# Verify library paths
echo $LD_LIBRARY_PATH
Method 3: Monitor Library Updates
Monitor library updates to track library changes:
Track Library Versions
# View library versions
ldconfig -p | grep libssl
# Check library modification times
find /usr/lib -name "*.so*" -mtime -1 -ls
# View library update history
grep "lib" /var/log/apt/history.log | tail -10
# Monitor library changes
ls -lt /usr/lib/*.so* | head -10
Detect Library Issues
# Check for library update errors
grep -i "library\|lib" /var/log/apt/history.log | grep -i "error\|fail"
# View library compatibility issues
ldd /usr/bin/application | grep -E "not found|version"
# Check library dependency conflicts
ldconfig -p | awk '{print $1}' | sort | uniq -d
Method 4: Automated Library Dependency Monitoring with Zuzia.app
Manual checks work while you are looking. To keep running them without you, Zuzia uses its agent and scheduled tasks.
How it works in Zuzia
- Install the Zuzia agent on the server with one command. CPU, RAM, disk, load and network metrics start reporting on their own, with alerts on a threshold, on drift from the server's normal, or on a disk fill-up forecast.
- Save the commands from this guide as a scheduled task and choose how often it runs, from every minute to once a year. The agent runs it on every host you pick.
- If a command fails, you get an alert right away by email, Slack, Discord, push (through your Pushover account) or SMS (through your Vonage account).
- The output of every run is kept, so you can look back at what changed. On paid plans, AI can read the output and alert you only when it spots a problem.
Setting it up
- Add the server in the Zuzia dashboard and install the agent.
- Create a scheduled task with the check commands below, then choose the hosts and how often it runs.
- Choose your notification channels. Turn on maintenance mode during planned work so it doesn't trigger alerts.
Custom Library Dependency Monitoring Commands
Add these commands as scheduled tasks:
# Check library dependencies
ldd /usr/bin/application | grep -v "not found"
# Verify library availability
ldconfig -p | grep libssl
# Detect missing libraries
ldd /usr/bin/application | grep "not found"
# Monitor library cache
ldconfig -p | wc -l
Best Practices
1. Monitor Library Dependencies Regularly
Check library dependencies every 12 hours. Use Zuzia.app for automated library monitoring. Verify library availability after updates.
2. Detect Missing Libraries
Identify missing libraries immediately. Track library dependencies. Fix library issues promptly.
3. Track Library Updates
Monitor library updates. Track library versions. Verify library compatibility after updates.
Troubleshooting
Missing Libraries Detected
When missing libraries are detected:
- Check library dependencies:
ldd /usr/bin/application - Identify missing libraries:
ldd /usr/bin/application | grep "not found" - Install missing libraries:
apt install library-name - Verify libraries installed:
ldd /usr/bin/application
Library Dependency Issues
When library dependency issues occur:
- Check library cache:
ldconfig -p - Update library cache:
ldconfig - Verify library paths:
echo $LD_LIBRARY_PATH - Test library loading:
ldd /usr/bin/application
FAQ
How often should I check library dependencies?
For production servers, check library dependencies every 12 hours. Zuzia.app can check dependencies automatically and alert when library issues are detected.
What library dependencies should I monitor?
Monitor library dependencies for all production applications, especially critical services. Focus on libraries that affect application functionality.
Can Zuzia.app detect missing libraries automatically?
Yes, Zuzia.app can detect missing libraries by checking library dependencies, verifying library availability, and alerting when libraries are missing.
Related guides, recipes, and problems
Related guides
Related recipes
Related problems