In this lesson, we're going to discuss
the best ways to troubleshoot software dependency issues
that you might encounter as a Linux system administrator.
Your troubleshooting efforts will first start out
by identifying the method that you are attempting to use
when installing the software in the first place,
because you're going to look at things differently
depending on whether you're using a package manager
like YUM, DNF, or APT,
or if you're actually installing the software manually
by compiling it yourself.
Now, if you're using a package manager,
you should first check the configuration files
for your specific package management system
to ensure that it's set up to query
in the right repositories
that are containing the software packages
and the required dependencies that you're trying to install.
For example, if you've set up your package manager
to use the local repository on your Linux server
but you haven't copied over all those packages
and dependencies into that repository,
well, guess what?
Your package manager is not going to be able to resolve
all the package dependencies for you automatically
'cause it can't find those files.
If you're using APT as your package manager,
make sure you look at the /etc/apt/sources.list.d directory,
and check your /etc/apt.conf configuration file.
If you're using YUM as your package manager,
make sure you look at the /etc/yum.repo.d directory,
and the /etc/yum.conf configuration file.
If you're using DNF,
make sure you check the DNF configuration file
at /etc/dnf/dnf.conf.
Remember, package managers like APT, YUM, and DNF
use information from inside the packages themselves
to discover what dependencies
each software requires for its installation.
When you're installing the package,
the package manager can automatically locate,
download, and install the right dependency packages for you
if you issue that option when you're running
the package manager's installation command
from the command line environment.
Now, if a piece of software doesn't appear
to be functioning properly after you install it,
you can verify that the software
and its dependencies were properly installed
by issuing the verify command.
For example, with the Red Hat package manager,
you can enter rpm -V and the package name
in order to verify that all the components
from the package and its dependencies
were properly installed.
If you want to identify what dependencies are required
before you install something,
you can do that with RPM
by typing rpm -qR and the package name
using the Red Hat package manager,
or yum deplist package name,
if you're using the YUM package manager.
If you're using a Debian based version of Linux,
you can instead use apt-cache depends
and the package name to list out the packages' dependencies
prior to trying to install that package.
Now, if your system cannot find the right dependency,
this is often because there's a different version
that's being requested than what actually exists
inside your repository.
If this is the case,
try running the APT update command first to ensure
that your package manager has a list
of the most recent versions
of the dependency packages that you're trying to install.
Also, if you can't download a dependency,
sometimes it's as simple as a broken network connection.
So I recommend that you try pinging
the repository server's host name
or IP address to validate that your system has a good
and solid connection all the way over
to the repost server that you're trying to use.
Now, if you're trying to manually compile a piece
of software and you start having issues,
it could be an issue with the compiling software itself.
In these cases you should check the documentation
for your compiler.
Normally this is going to be GCC
if you're using a Linux system.
But you can also use different compilers
on your Linux system if you install those.
To find out what libraries and dependencies are required
for a particular piece of software,
you're going to run the LDD command
against that binary.
To use this, simply enter ldd option
and the program binary at the command prompt.
Once you do that, you're going to get back a list
of library files and their versions.
Now you need to verify the library file versions
for those files and versions are actually available
on your system.
And once you do that,
you should be able to compile that program.
If you're having issues compiling the software,
it's also possible that you might need to run
the make install command using sudo
to assume root privileges.
Sometimes in Linux, you're going to find
that you need to elevate your permissions
in order to compile certain programs or code
depending on what binaries are being called.
Finally, let's take a moment
and talk about updating and upgrading software.
This is often done when a security bug needs to
be fixed or patched.
And when you do this,
you always need to have a back out plan.
This means you know upfront what you're going to do
if something goes wrong.
For example, if you're upgrading the software
from version 1.1 to version 2.0,
this could cause massive issues
and cause a big disruption to your business
if version two breaks some kind
of backward compatibility with other things on your system.
Or let's say you're upgrading your version of PHP,
but you don't upgrade your version of Apache.
This can cause big issues
and compatibility for your website
if it's being run on that particular Linux server.
For these reasons, it's important
that you always have a solid backup before you get started,
as well as a good back out plan and restoration plan
for how you're going to remove the problem software
and get back to a known good configuration
if something goes wrong.
Remember, it's always a good idea to test upgrades
and patches in a development environment
or a staging environment first.
And then once you've figured out everything's working okay,
you can then apply those upgrades
to your production servers.
This is going to minimize your chances
of breaking things that would directly
affect your business operations and cause outages.
Now, if things go wrong when you're trying
to update or install a piece of software,
you should go check the installation logs
to determine exactly what happened
and how you can best fix and overcome those issues.
Because most of the time,
the installation logs will tell you exactly what went wrong,
such as a missing dependency or incorrect file permissions.