Tag Archives: how to remove package using yum

Linux package removal

Package removal in Linux (YUM & APT)

Different types of package removal in Linux explained with examples. Learn package removal or uninstall on a yum or apt-based system.

Package removal in Linux

This article is part of the YUM series. Other articles in this series can be found at below links :

We will be seeing how to uninstall packages from YUM and APT based Linux systems. Package removal also knows as an erasing package from the system.

Package removal on YUM based system

Removing package using yum

On YUM based system like Red Hat or CentOS, the package can be removed by supplying erase or remove argument to yum command along with package name. For example to remove telnet, we will use yum remove telnet

# yum remove telnet
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-60.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                      Arch                         Version                             Repository                                               Size
=============================================================================================================================================================
Removing:
 telnet                       x86_64                       1:0.17-60.el7                       @rhui-REGION-rhel-server-releases                       113 k

Transaction Summary
=============================================================================================================================================================
Remove  1 Package

Installed size: 113 k
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:telnet-0.17-60.el7.x86_64                                                                                                               1/1
  Verifying  : 1:telnet-0.17-60.el7.x86_64                                                                                                               1/1

Removed:
  telnet.x86_64 1:0.17-60.el7

Complete!

The above output will be the same even if you use yum erase telnet command. Before removing it will print package details to be removed on screen and ask for confirmation to avoid unwanted removals.

Removing package using rpm command

Same task can be achieved by using rpm command with erase -e option.

# rpm -evh telnet
Preparing...                          ################################# [100%]
Cleaning up / removing...
   1:telnet-1:0.17-60.el7             ################################# [100%]

In above example we used -e (erase), -v (verbose) and -h (print hash marks) along with name of package.

Package removal on APT based system

Removing package using apt-get

On APT based systems like Ubuntu or Debian, the package can be removed with apt-get remove <package_name> command. Note that like YUM this command doesn’t support erase option.

# apt-get remove telnet                                                                                                                                      
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  telnet
0 upgraded, 0 newly installed, 1 to remove and 60 not upgraded.
After this operation, 182 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 81678 files and directories currently installed.)
Removing telnet (0.17-40) ...
Processing triggers for man-db (2.7.5-1) ...

apt-get to asks for confirmation before removing package from system.

Removing package using dpkg

With Debian package manager command i.e. dpkg, this can be done using --remove argument.

# dpkg --remove telnet
(Reading database ... 81678 files and directories currently installed.)
Removing telnet (0.17-40) ...
Processing triggers for man-db (2.7.5-1) ...

See above output as it removes telnet.

Observe that dpkg or rpm commands don’t ask for user confirmation before removing the package.