Strictly speaking, Linux is the kernel. Linux distribution is made of Linux kernel, installation scripts, shell, compilers, desktop, and other components. Hence, Linux command to uninstall package or software depends upon Linux distribution name and type. This page explains how to uninstall package or software on various Linux distros using the command line.
Linux uninstall package / software
- First, you need to find a list of all installed packages on Linux.
- To uninstall an application, you need to use Linux distro-specific command. For example, use the apt command on Debian or Ubuntu Linux. RHEL/CentOS/Fedora Linux users need to run either the dnf or yum command and so on.
- Finally, we can use various commands for verification of the uninstallation of a program on Linux.
Let us see all commands in action to uninstall a program on Linux.
Ubuntu/Debian Linux uninstall software
The syntax is as follows to list all installed packages on Debian or Ubuntu Linux using the apt command:
apt list --installed
Another option for finding out package names is to use the dpkg command:
dpkg --list | grep '^ii'
It will be a big list, and we need to scroll through package names on a computer screen until you find the one you want to uninstall. Of course, we can use the grep command to filter out the list as follows:
dpkg --list | grep -i 'package'
apt list --installed \*package\*
apt list --installed \*ping\*
dpkg --list | grep -i 'firefox'
dpkg --list | grep -i 'ping'
Let us uninstall the program named 2ping using the apt-get command or apt command. For example:
sudo apt remove 2ping
sudo apt remove --purge 2ping
sudo apt-get remove 2ping
sudo apt-get --purge remove 2ping
First, you need to enter your password when prompted and press the [Enter] key. The --purge is optional. We use it when we need to uninstall the package and all of its configuration files. When prompted, “Do you want to continue?”, type a y and press the [Enter] key:
Do not pass the --purge option if you don’t want to delete the config file for the package. For example, to remove the nginx package and leave all config files as it is on disk, run:
sudo apt remove nginx
#### OR #####
sudo apt-get remove nginx
Finally verify that nginx has been removed or uninstalled from the system, run:
dpkg --list | grep nginx
apt list --installed | grep nginx
Now you know how to uninstall package on a Debian or Ubuntu or Mint Linux. Let us see other distros.
We need to use the yum command for CentOS/RHEL v6.x/7.x. First get a list, run:
sudo yum list installed
sudo yum list installed | grep package
sudo yum list installed | grep zip
To uninstall the package named zip, run:
sudo yum remove zip
Use the dnf command on a CentOS/RHEL/Oracle Linux 8 as follows to uninstall software:
sudo dnf list installed
sudo dnf list installed | grep zip
sudo dnf remove zip
Again, we need to the dnf command as follows:
## List all installed packages ##
sudo dnf list installed
## Filter out the package named httpd ##
sudo dnf list installed | grep httpd
## Delete the httpd ##
sudo dnf remove httpd
We use the pacman command on Arch Linux to uninstall software. Pass the Q to list all installed packages on Arch Linux:
sudo pacman Q
sudo pacman Q | more
sudo pacman Q | grep sl
To delete/remove the sl package in Arch, run:
sudo pacman -R sl
OpenSUSE or SUSE Linux removing package command
We are going to use the zypper command. To list all installed packages in SUSE/OpenSUSE, run:
sudo zypper packages --installed-only
sudo zypper packages --installed-only | grep -i package
sudo zypper packages --installed-only | grep -i zip
I am going to remove the zip package, enter:
sudo zypper remove package
sudo zypper remove zip
Use the apk command to list installed packages only:
sudo apk list
sudo apk list -I
sudo apk list -I 'package'
sudo apk list -I 'zip'
To uninstall the zip Linux uninstall software pass the del as follows:
sudo apk del pkg
sudo apk del zip
You learned how to uninstall package on popular Linux distros. I would strongly recommend reading the man pages: