Login | Register RSS

Package Management Basics - Part 7

In this installment of our Linux package management basics tutorial, we will be covering several slightly advanced package management abilities.  This will teach you some additional ways to manage your system, once you have the basics under your belt.

* NOTE: All of the example commands below assume you are performing them as 'root' or some other authorized administrative user.  You can also perform these commands through 'sudo', if you do not wish to login directly as 'root'.  To do this via 'sudo', simple prepend the word 'sudo', followed by a space, before the given command.

The remainder of this tutorial, relates to more advanced package management abilities.  Some of these use the 'package-cleanup' command.  You likely will need to install the 'yum-utils' package to obtain this ability..

Find duplicate packages:

At times you may have 2 or more versions of the same package installed.  You can use this command to detect & list the duplicate packages:

package-cleanup --dupes;

You can use this command to automatically detect & remove the older duplicate packages:

package-cleanup --cleandupes;

Locate orphan packages:

Orphan packages occur when the package manager detects that the given package is either not part of your system's yum repository any longer or are left over packages which are not dependencies of anything currently installed.  Under these different situations, it is possible for you to obtain a list of these orphaned packages.  You can obtain a list of those packages using this command:

package-cleanup --orphans;

Locate problem packages:

Sometimes an existing package can have problems.  A typical case is where a given dependency of an installed package is not fulfilled.  You can use the following command to obtain a list of those problem packages.

package-cleanup --problems;

Reinstalling packages:

Sometimes a given package is so messed up, you simply need to reinstall it.  You can use the following command to reinstall the package.

yum reinstall PACKAGENAME;

Where 'PACKAGENAME' is the name of the given package to reinstall.  Please note just like with package installations, you can specify multiple package names or use partial matching with wild cards.

Remove old kernels:

Most current versions of Linux default to a limited # of kernels it keeps around.  However if you would like to automatically remove all old kernels & its related kernel development packages, you can use the following command:

package-cleanup --oldkernels;

Replicate a system's installed packages:

There will be times where you will need to rebuild a given workstation/server or install the sames packages on a different system.  You would accomplish this, by first obtaining a file which lists all of the packages that are installed on the original system.  As discussed in an earlier part of this tutorial, you can use a command like this:

rpm -qa > installed.txt;

Transfer that file to whatever system you wish to install the sames packages on.  Then use this command to tell install them on that system.

yum -y --skip-broken install $(cat installed.txt);

At this point yum will attempt to install as many of those listed packages as possible.  It will skip over all of the ones that cannot be installed, due to dependency issues or other problems.

At this point you are technically done...  However I recommend you compare what is installed on the given system to the package list in your install file. To do this, run these commands:

rpm -qa > installed_new.txt;
diff installed.txt installed_new.txt;

The resulting information will tell you what packages differ.  This will let you easily see the difference between them & determine if anything important was missed.  You can then take appropriate action to correct the matter, as necessary.

Repair a severely damaged system:

I know we touched upon this earlier, but it's important to note that if you run into major problems with your system, where the OS is severely messed up, it is possible to repair the entire OS by telling yum to reinstall everything all over again.  To do that, use this command:

yum -y --skip-broken reinstall \*;

Basically this tells yum to reinstall every package that is currently installed, and skip those packages with dependency issues or other problems.  Overall, it should help bring your system back to a usable state.  At which point you can backup your data, before you lose everything.  I have found this useful after a failed upgrade to the next version of my selected Linux distribution; where only half of the new version's OS installed successfully.

* WARNING: If you actually have repair your OS in this fashion, it's highly recommended that you backup your data immediately & then rebuild the machine from scratch to prevent the underlying problem(s) from causing any further issues.

At this point you should have all the basics & several advanced methods to handle your package management needs.  Anything beyond that, is beyond the scope of this tutorial & should be independently researched before proceeding.

If you like this site or any of its content, please help promote it. Use the social media buttons below to help spread the word. Don't forget to post in the comments section.

  Print   Email
Latest Blog Posts:
Latest Q&A Posts:

© 2017 BuildDesignCreate.com • All Rights Reserved
Privacy PolicyAdvertise with UsContact UsSite Map