Quick Links

Key Takeaways

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?

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.

Running "dpkg --list" in the Termminal on Ubuntu.

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.

GIMP listed as an installed program.

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.

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.

Run "sudo apt purge gimp" to uninstall GIMP and remove the configuration files on Ubuntu, or any Debian installation.

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.

GIMP was successfully removed.

If you don't want to remove the configuration files, simply substitute the command removefor purge, as shown in the following command.

sudo apt remove gimp

Enter "sudo apt remove gimp" to remove just GIMP, but leave the configuration files in place.

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

Run "sudo apt autoremove" to remove a package and all of the dependencies it installed.

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

Run "sudo apt purge --autoremove gimp" to remove all of GIMP's dependencies and the configuration files.

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.

Run "sudo apt clean" to remove archive files.

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?

Linux Commands

Files

tar · pv · cat · tac · chmod · grep ·  diff · sed · ar · man · pushd · popd · fsck · testdisk · seq · fd · pandoc · cd · $PATH · awk · join · jq · fold · uniq · journalctl · tail · stat · ls · fstab · echo · less · chgrp · chown · rev · look · strings · type · rename · zip · unzip · mount · umount · install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · vi · nano · mkdir · du · ln · patch · convert · rclone · shred · srm · scp · gzip · chattr · cut · find · umask · wc · tr

Processes

alias · screen · top · nice · renice · progress · strace · systemd · tmux · chsh · history · at · batch · free · which · dmesg · chfn · usermod · ps · chroot · xargs · tty · pinky · lsof · vmstat · timeout · wall · yes · kill · sleep · sudo · su · time · groupadd · usermod · groups · lshw · shutdown · reboot · halt · poweroff · passwd · lscpu · crontab · date · bg · fg · pidof · nohup · pmap

Networking

netstat · ping · traceroute · ip · ss · whois · fail2ban · bmon · dig · finger · nmap · ftp · curl · wget · who · whoami · w · iptables · ssh-keygen · ufw · arping · firewalld

RELATED: Best Linux Laptops for Developers and Enthusiasts

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

Run "dnf list --installed" to list installed packages on Fedora.

Scroll through the list until you find the program that you're looking for.

GIMP highlighted on the installed package list.

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:

Run "sudo dng remove gimp" to uninstall GIMP on Fedora.

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.

Run "sudo dnf autoremove neofetch" to remove Neofetch and all of its dependencies on Fedora.

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