RHEL7: How to keep your system clean.

Share this link

Presentation

When installing and removing packages, it is very easy to get a system cluttered after some time.
For example, install the httpd package and then remove it.
At first, 5 packages are installed because the httpd package comes with 4 other packages as dependencies.

# yum install -y httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
...
================================================================================
 Package           Arch         Version                        Repository  Size
================================================================================
Installing:
 httpd             x86_64       2.4.6-17.el7.centos.1          base       2.7 M
Installing for dependencies:
 apr               x86_64       1.4.8-3.el7                    base       103 k
 apr-util          x86_64       1.5.2-6.el7                    base        92 k
 httpd-tools       x86_64       2.4.6-17.el7.centos.1          base        77 k
 mailcap           noarch       2.1.41-2.el7                   base        31 k

Transaction Summary
================================================================================
Install  1 Package (+4 Dependent packages)
...
Complete!

Then, remove the httpd package, only one package is removed!

# yum remove -y httpd
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
...
================================================================================
 Package       Arch           Version                       Repository     Size
================================================================================
Removing:
 httpd         x86_64         2.4.6-17.el7.centos.1         @base         9.3 M

Transaction Summary
================================================================================
Remove  1 Package
...
Complete!

Solutions

There are at least two solutions to this problem.
You can use the yum autoremove command after each removal.

# yum autoremove -y
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
...
================================================================================
 Package           Arch         Version                       Repository   Size
================================================================================
Removing:
 httpd-tools       x86_64       2.4.6-17.el7.centos.1         @base       168 k
 mailcap           noarch       2.1.41-2.el7                  @base        62 k
Removing for dependencies:
 apr               x86_64       1.4.8-3.el7                   @base       221 k
 apr-util          x86_64       1.5.2-6.el7                   @base       194 k

Transaction Summary
================================================================================
Remove  2 Packages (+2 Dependent packages)
...
Complete!

A more transparent solution and less prone to oversight is to paste the following line into the /etc/yum.conf file:

clean_requirements_on_remove=1

So, when you remove a package (here httpd), you get the package and all of its dependencies removed:

# yum remove httpd -y
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
...
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
httpd x86_64 2.4.6-17.el7.centos.1 @base 9.3 M
Removing for dependencies:
apr x86_64 1.4.8-3.el7 @base 221 k
apr-util x86_64 1.5.2-6.el7 @base 194 k
httpd-tools x86_64 2.4.6-17.el7.centos.1 @base 168 k
mailcap noarch 2.1.41-2.el7 @base 62 k

Transaction Summary
================================================================================
Remove 1 Package (+4 Dependent packages)
...
Complete!

Going further

The two previous solutions are perfectly safe. You don’t risk removing packages you don’t want to.
However, it is possible to go further and remove unneeded packages in your system but you need to take extra precautions.
To get the list of unneeded packages, type:

# package-cleanup --leaves
Loaded plugins: fastestmirror, langpacks
libertas-sd8686-firmware-20140213-0.3.git4164c23.el7.noarch
libertas-sd8787-firmware-20140213-0.3.git4164c23.el7.noarch
libertas-usb8388-firmware-20140213-0.3.git4164c23.el7.noarch
libreport-plugin-mailx-2.1.11-10.el7.centos.x86_64

Then, in a second step, you can decide if you want to remove them one by one.
It is indeed not advisable to automate this procedure if you don’t want to take any risk!

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading...

Leave a Reply

Be the First to Comment!

Notify of
wpDiscuz

RHCSA7: Task of the day

Allowed time: 5 minutes.
Create a user called tom. Create a directory named /private. Use an acl to only allow access (rwx) to tom to the private directory.

RHCE7: Task of the day

Allowed time: 15 minutes.
Configure a httpd server with a password protected directory under the /var/www/html/private directory.

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...

Recent Comments