How to Uninstall Software Using the Command Line in Linux
Enter “apt remove (program name)” into a Terminal or the command line to uninstall a program from Ubuntu or any other Debian-based Linux distribution. Run “dnf remove (program)” in a command-line interface or the Terminal to remove a program from Fedora.
Linux distributions provide different methods for installing software. You can install software from the standard Ubuntu or Fedora software repositories using the Software Center, from outside of the standard Ubuntu or Fedora software repositories, or by compiling source code. However, what if you need to uninstall a program?
Mục lục bài viết
How to Uninstall Software Using the Command Line on Ubuntu
If you’ve installed software from the Ubuntu software repositories using the Ubuntu Software Center, you can use the Ubuntu Software Center to uninstall that software as well. However, if you’re more comfortable using the command line, we’ll show you an easy way to see what’s installed on your system and uninstall programs.
The command line uninstallation methods will work with any Debian-based Linux distribution, not just Ubuntu.
If you have an idea of what you want to uninstall, but you don’t know the exact name, see our article about finding out exact package names in Linux. You can also use the “dpkg” command to see a list of all installed packages on your computer. Press Ctrl+Alt+T to open a Terminal window, then enter the following command into the prompt:
dpkg --list
Or:
apt list --installed
The commands will display the same content, but it’ll be displayed a little differently.
Scroll through the list of installed packages in the Terminal window to find the one you want to uninstall. Note the full name of the package.
To uninstall a program, use the apt
command, which is the general command for installing programs and manipulating installed programs. For example, the following command uninstalls gimp and deletes all the configuration files, using the purge
command.
sudo apt purge gimp
Enter your password when prompted and press Enter.
Note: The password does not display as you type it. However, you can choose to display asterisks as you type the password.
The uninstallation process begins and a summary of the actions to be taken displays. When asked if you want to continue, type a “y” and press Enter.
The installation process continues. When it’s done, type “exit” at the prompt and press “Enter” to close the Terminal window, or click the “X” button in the upper-left corner of the window.
If you don’t want to remove the configuration files, simply substitute the command remove
for purge
, as shown in the following command.
sudo apt remove gimp
Programs installed in Linux — just like Windows and MacOS — depend on other packages to function. When you uninstall a program, there may be packages that the uninstalled program depended upon that are no longer used. To remove any unused packages, use the “autoremove” command, as shown in the following example.
sudo apt autoremove
You can combine the two commands for removing a program and removing dependencies that are no longer being used into one, as shown below (two dashes before “auto-remove”).
sudo apt purge --auto-remove gimp
If you’re short on space, you can use the “clean” command to remove downloaded archive files, as shown below.
sudo apt clean
This command removes the aptitude cache in “/var/cache/apt/archives”. When you install a program, the package file is downloaded and stored in that directory. You don’t need to keep the files in that directory. However, there is a potential drawback from deleting them: if you decide to install any of those programs again, the packages will have to be downloaded again.
The APT is a handy tool that makes downloading, installing, and uninstalling programs quick and easy. For more information about using the “apt” command, type “apt” at the prompt and press Enter.
The older “apt-get” command will accept most of the same arguments as the “apt” command demonstrated here, and you can use that instead if you prefer it.
RELATED: apt vs. apt-get: What’s the Difference on Linux?
How to Uninstall Software Using the Command Line in Fedora
Fedora is another popular Linux distribution, but uses a different package manager named DNF. Fortunately, DNF shares a lot its syntax with APT — that means if you’re familiar with APT from Debian, you won’t have a difficult time using DNF.
RELATED: What Is Fedora Linux?
Open up a Terminal window — or just type in the command-line interface (CLI) — and run the following command to list the installed libraries and programs. It’s handy if you know what you want to remove but don’t recall the specific name.
dnf list --installed
Scroll through the list until you find the program that you’re looking for.
There are two quick ways to remove a program using DNF.
- sudo dnf remove — Removes only the specified program.
- sudo dnf autoremove — Removes the specified program and any additional dependencies it installed.
Remove is generally a safer command than autoremove. Autoremove has occasionally been known to get a bit overzealous and remove something it shouldn’t. If you don’t care too much about making sure stray dependencies get removed, just use sudo dnf remove
.
Enter the following command into the Terminal or CLI, then enter your password.
sudo dnf remove (program name)
For example, if you wanted to remove the GIMP from your PC, it’d look like this:
Just enter “y” and GIMP will be removed.
If you use autoremove instead, the prompt will list the specific program you want to remove, as well as any dependencies that installed with it. Otherwise, it works just like remove.
Fedora is usually pretty good at grabbing only the correct dependencies, but if you notice something on the “Removing Unused Dependencies” list that you’d like to keep, you can manually flag it to be kept. Enter the following command in a command line to keep a dependency:
dnf mark install (Dependency/Package Name)
Accidentally uninstalling a package isn’t a big deal — just use dnf install (package)
to reinstall it.
Of course, adding and removing packages is only the beginning of running a Linux installation. There are a handful of other basic commands that you should know if you’re going to use Linux regularly.
RELATED: 10 Basic Linux Commands for Beginners