Installing and removing packages in yum is very easy as yum calculates dependencies, downloads packages, and installs—relieving the user from having to do it manually. Using the yum downloadonly plugin, you can download packages from repositories into a named directory. You can also do local installs just like RPM.
- [Instructor] Installing packages in groups with Yum is pretty easy. We'll need to elevate privileges to install though. If we don't want to press Y each time we install a package, just pass it as an option. Type in sudo yum -y install tree and hit Enter. Now type in your password and hit Enter again. Tree allows us to view our file system as a hierarchy on the command line. The tree package did not have a dependency.
Let's install something with dependencies. Type in clear. Type in sudo yum install konsole, with a K, and hit Enter. Notice that we have over 80 dependencies. Konsole is a terminal emulator for the KDE desktop. I'm currently using GNOME 3, so the reason there's so many dependencies is because it needs a lot of KDE libraries that were not installed with GNOME. Press n for no. Earlier in this course we downloaded some packages without installing them.
First we had to install the Yum Download Plugin. If you've already done this then skip this step. However, doing it again won't hurt anything. Let's install the plugin first. Type in clear and then hit Enter. Now type in sudo yum install yum-plugin-downloadonly and hit Enter. Press y to install. Now that we've installed the plugin let's download some packages.
Type in clear and then type in sudo yum install --downloadonly --downloaddir=/tmp/packages, and then the name of the package we're going to download is whois, and hit Enter. This uses the downloadonly plugin to download the whois package. Now let's cd /tmp/packages and type in ls.
I can see the whois package that I downloaded. You may have more packages than this from previous videos if you haven't deleted them. Yum has the ability to install local packages just like RPM. However, unlike RPM, Yum will go up to the repositories to satisfy dependencies. To install a local package, we'll use the local install sub command. Type in clear, and type in sudo yum localinstall whois and then I'm going to hit my Tab key to complete the line for me, and hit Enter, and press y to install.
This installs the downloaded whois package. After a package has been installed, we may want to reinstall the exact same version. We often do this as a means of troubleshooting problems. You could uninstall the package and then install it again or use Yum's reinstall sub command. Type in clear and then type in sudo yum reinstall whois and hit Enter. This will download a new RPM package from the repositories and reinstall it over the old one. Press y to install.
Sometimes our repositories can get out of sync and a dependency can't be met. If we are attempting to install 100 packages and one has a dependency problem, the entire update will fail. If we don't want to hold up the other 99 packages from updating while the repository maintainers are ironing out the problem, we can pass --skip-broken to Yum to have it install all packages that are not broken. I cannot simulate a broken repository, but I can run reinstall on the whois package with a --skip-broken option turned on.
Type in clear and then hit Enter, and then type in sudo yum reinstall --skip-broken whois and hit Enter. And press y to install. - -skip-broken works with install, reinstall, and update sub commands. Similar to reinstalling a package is upgrading. To upgrade a package to the newest version we'll use the upgrade sub command. Let's find a package that needs upgrading first. Type in yum list updates and hit Enter.
In my list I see the xz command has an update. To upgrade xz to the latest version, type in sudo yum upgrade xz and hit Enter. And press y to install. If you want to remove a package just use the remove sub command. Type in sudo yum remove whois and hit Enter. And once again press y to remove. This removes whois without issues.
When yum removes a package it leaves the configuration file behind in case you're upgrading or want to run that service in the future. Also, yum only removes the packages specified and leaves behind any dependencies that were installed. Let's install Wireshark and its dependencies. Wireshark is a network sniffer program and has dependencies. Wireshark will be a good example for this exercise. Type in sudo yum install -y wireshark and hit Enter.
Notice that Wireshark has two dependencies. Now let's remove Wireshark using the remove sub command. Type in sudo yum remove wireshark and hit Enter. Notice I did not pass it a -y. I wanted to see what it was removing, and from the output we can see that it's only removing Wireshark and leaving the dependencies there. Press End to cancel this. If we want to remove a package and its dependencies if they aren't being used by other packages then we can use the autoremove sub command.
So type in sudo yum autoremove wireshark and hit Enter. Now we see that it's removing Wireshark and its dependencies. Although Yum will take a -y argument for remove and autoremove, I don't recommend it. If you want to remove one package and all other software that requires that package, Yum will attempt to uninstall your entire OS. Passing the -y option to Yum means it won't ask you first, which could be disastrous. If you want to go one step further to clean up old, unused packages we can use the package-cleanup command from the yum-utils package.
Let's make sure it's installed first. Type in clear and then type in sudo yum install -y yum-utils and hit Enter. Now that package-utils is installed, let's run package-cleanup with the --leaves option. Hit Enter. Notice that package-cleanup didn't do anything but give us a list of packages that are no longer needed. It's still up to us to use Yum to remove them manually.
Instructor Grant McWilliams covers network and internet services administration, kernel management, and intrusion prevention. He shows how to make your systems more efficient with virtualization, manage users and groups, and lock everything down with SELinux mandatory access control. Plus, get access to 25 PDF "cheat sheets" and 100 practice questions so you can solidify and test your knowledge.
- Installing Linux on a physical machine
- Managing systemd services
- Managing reoccurring jobs with cron
- Limiting system access
- Configuring networking
- Creating, editing, and moving files and directories
- Analyzing text with grep and regular expressions
- Installing software and packages
- Managing the kernel
- Managing users, accounts, and groups
- Setting permissions
- Using access control lists
- Securing Linux with SELinux
- Accessing Linux remotely
- Configuring local storage