Remove Package in Ubuntu: Linux How to Uninstall

Posted on by Alison Gray | Updated:
Reading Time: 12 minutes

Ubuntu is a very popular Linux distribution, providing an easy-to-use interface and a large number of software packages. However, people often inquiry about how to uninstall programs in Ubuntu.

Though it is essential to install the necessary packages, it is equally important to uninstall packages that you do not need. Learn various methods that will enable you to remove packages from your Ubuntu system efficiently.

This tutorial demonstrates how to quickly and easily uninstall software on Ubuntu. Uninstalling software can be done using several techniques. It shows you how to uninstall software using these various methods.

On the Ubuntu distribution of Linux, the main applications or methods used to install and uninstall software packages are listed below:

Each of these methods has specific methods to uninstall software. We will review how to uninstall programs in Ubuntu.

In preparation for uninstalling software from Ubuntu, you will need sudo permissions. By accessing the sudo permissions level before running commands, you can avoid having to authenticate these root-level commands each time.  

Methods for Installing Ubuntu Software Packages

Ubuntu provides easy access to an extensive range of applications through its software center. Additionally, users can install packages using the terminal, the apt-get command, or the apt utility.

Method #1: Using the Ubuntu Software Center

One of the simplest ways to install packages in Ubuntu is to use the Ubuntu Software Center. This graphical tool allows you to browse and search for packages that are available in the official Ubuntu repositories. To use the Ubuntu Software Center, simply follow these steps:

  1. Open the Ubuntu Software Center from the Applications menu.
  2. Use the search field to search for the software package you want to install.
  3. Select the package from the search results.
  4. Click the Install button.

The Ubuntu Software Center will handle the rest, downloading and installing the package and any dependencies it requires. This method is one of the easiest ways to uninstall programs in Ubuntu.

Method #2: Using the apt Command

The apt command is a powerful package management tool that allows you to interact with the Ubuntu package repositories directly from the command line. The basic commands for using apt for installing packages are presented below:

  • sudo apt update — Update the local package index with the latest information from the repositories.
  • sudo apt install [package] — Install a new package.
  • sudo apt remove [package] — Uninstall a package.
  • sudo apt upgrade — Upgrade all packages to their latest available versions.
  • sudo apt autoremove — Remove all packages that were installed automatically as dependencies and are no longer required.

Below is an example of how to install a package using the apt command:

sudo apt update

sudo apt install apache2

The above example’s commands will update the local package index, and it will install the Apache web server package.

Method #3: Using a PPA (Personal Package Archive)

A PPA, or Personal Package Archive, is a collection of Ubuntu binary packages that are built and hosted by a specific individual or organization. PPAs can contain packages that are not available in the official Ubuntu repositories or they can contain packages that are in development and have not yet been added to the official repositories.

To use a PPA, you first need to add it to your system by following these steps:

  1. Find the PPA you want to use.
  2. Copy the PPA URL to your clipboard.
  3. Open a terminal session and type the following command, replacing [ppa-url] with the URL you copied in the previous step.
sudo add-apt-repository [ppa-url]

4. Enter your password when prompted.

5. Update — using the below command — the local package index with the latest information from the new PPA:

sudo apt update

Method for Finding Installed Software on Ubuntu

One of the best and easiest ways to find installed software on Ubuntu is by using the terminal. Follow the steps below to search for installed applications using the command line.

Step #1: Open a Terminal Session

Open the terminal window by pressing Ctrl + Alt + T keys or you can open it from the applications menu.

Step #2: Run dpkg Command

The dpkg command is used to find information about installed packages. To get a list of installed applications, type the following command and press the Enter key:

sudo dpkg --list

The command above will list all the installed packages on your Ubuntu system.

Step #3: Search for Installed Software

To search for a specific installed software, use the following command:

sudo dpkg --list | grep <software_name>

For example, to find the installed version of Firefox web browser, run the following command:

sudo dpkg --list | grep firefox

More Information on Listing All Installed Software Packages on Linux

Are you curious about how to uninstall a program on Linux?

If you have an idea of what you want to uninstall, but you don’t know the exact name, you can find out the exact package names in Linux. Remember, you can use the apt or dpkg command to see a list of all installed packages on your computer. Press the Ctrl + Alt + T keys to open a terminal window. Type one the following command at the prompt and press the Enter key:

sudo apt list --installed
sudo apt-cache search <package_name> 

Or:

sudo dpkg --list

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. Then, type in one of the following commands:

sudo apt remove <package_name> 
sudo apt remove <package_name_1> <package_name_2>
sudoapt purge <package_name> 

These commands are useful for specific situations. See the following sections for more details:

sudo apt-get clean

This command removes the aptitude cache located in /var/cache/apt/archives. When you install a program, the package file is downloaded and stored in that directory. You do not need to keep the data in that directory. However, the only drawback of deleting that information is that if you decide to reinstall any of those programs again, the packages would have to be downloaded again.

Primary Methods for Uninstalling Software

Different operating systems use various commands to execute actions. To interact with the packages on Ubuntu, you will typically want to use the apt command. The apt command's primary function is to install software on Ubuntu systems and remove unwanted software. The user can choose between two options:

  • apt-get purge
  • apt-get remove

You will see this apt-get command used numerous times in the instructions for uninstalling software on Ubuntu below. Let's learn how to uninstall programs in Ubuntu.

Method #1: Using the apt-get purge Command for Ubuntu Uninstalls

The apt-get purge command can be used to remove packages in Ubuntu (unnecessary packages, including configuration files, listed directories, and files). It deletes the software entirely from the system.

It's essential to back up any necessary files before running this command (example shown below). You can use the following command, substituting <package_name> with the desired package for purging:

sudo apt-get purge <package_name>

Method #2: Using the apt-get remove Command for Ubuntu Uninstalls

The apt-get remove command removes Ubuntu packages, but it does not remove configuration files and other dependencies. It only removes the package and its core components. See below for an example of the command. Use the following command, again substituting <package_name> with the desired package for removal:

sudo apt-get remove <package_name>

Method #3: Using the apt-get –f install or apt-get --fix-broken install Command to Fix Software Packages

This option uses the -for --fix-brokenflags to examine the installed applications and will attempt to fix any packages it finds that are broken. These options repair broken packages and resolve any package dependencies that have inadvertently been removed. Running these options will scan the entire system for broken or missing packages. See the commands below:

sudo apt-get –f install

These flags only replace found packages that are broken and do not remove any packages. They will attempt to correct a system with broken dependencies in place. This option, when used with install/remove, can omit any packages to permit apt to deduce a likely solution. If packages are specified, these have to completely correct the problem:

sudo apt-get --fix-broken install

Method #4: Using the apt-get autoremove Command to Remove Ubuntu Software Package Dependencies

When removing packages, the apt-get command may leave behind other dependencies that were installed when the software was installed. To remove any dependencies, such as the applications and libraries used by the software you once installed that is no longer in use, you can do some housekeeping through the apt-get autoremove. Running the below apt-get autoremove command removes these dependencies, freeing up disk space and keeping the system clean:

sudo apt-get autoremove

This command will list all the obsolete and unused packages and any leftover dependencies taking up valuable space on your system. The system will also prompt with a Y/N option to reconfirm the uninstallation procedure. When you click Y, the process will begin, and the unwanted software dependencies will be removed from your system. This is a useful method for how to uninstall programs in Ubuntu.

Method #5: Using the ppa-purge Command to Uninstall Software Previously Installed Using a PPA

Users may occasionally install software from PPA repositories and may want to uninstall them from the Ubuntu system. To uninstall the software previously installed via a PPA, use the two ppa-purge commands:

sudo apt-get install ppa-purge

sudo ppa-purge <ppa:repository-name>

The first command removes the software installed via the PPA. The second command removes the PPA from sources.list.
Top

Additional Methods for Uninstalling Software

Using the command-line interface or package managers isn't always the best way to uninstall software; therefore, Ubuntu features additional software for removing packages outside of the command-line interface. Let's review how to uninstall a program on Linux via the options below.

Method #1: Uninstalling Software via the Synaptic Package Manager Uninstall Steps

Synaptic is the GUI package manager for Ubuntu and is not usually installed on the server version of Ubuntu. It is included here to provide a more complete overview of uninstall methods. To uninstall software using Synaptic take the steps that follow.

Step #1a: Launch Synaptic Package Manager

To start using Synaptic Package Manager, all you have to do is launch it from your Linux desktop. Once opened, start exploring and installing or uninstalling the packages you need to manage with ease.

Step #1b: Search for the Package to Uninstall

To find the package you want to uninstall, use the search function in Synaptic's top menu. Simply type in the name of the package you want to remove, and Synaptic will display a list of all related packages on your system.

Step #1c: Select Package to Remove

Scroll through the list of installed applications and click on the software to highlight it. After you've found the package that you want to uninstall, right-click on its name to open a context menu. From there, select Mark for Removal.

Note that Synaptic will automatically mark any dependencies for removal as well. This is usually what you want but be sure to double-check the list of packages that will be removed before proceeding.

Step #1d: Apply Changes

Click Apply. This will uninstall the software but leave the configuration files intact. To delete the associated configuration files along with the software, select Mark for Complete Removal instead.

Step #1e: Wait for Uninstall to Finish

After you've initiated the uninstallation process, Synaptic will display the progress of the removal. Depending on the size of the package and any dependencies, the process might take several seconds to several minutes.

Once the uninstallation is complete, Synaptic will display a message indicating that the changes have been successfully applied. Congratulations on learning this technique for how to uninstall programs in Ubuntu.

Method #2: Finding & Uninstalling Software Packages via the dpkg --list and dpkg–query -l Uninstall Steps

Finding software packages in dpkg requires running the dpkg --list command to get a list of all installed packages in Ubuntu. Before uninstalling a software package, it is a good practice to note the entire software name for accuracy. To list software installed via dpkg, use one of these commands. If you know the name of the software, you can search for the command using theless command as shown below:

dpkg ––list
dpkg–query –l | less

If you do not know the full name, you can also search for a partial name using a grep command:

dpkg–query –l | grep package_name
dpkg–query –l | grep *partial_name*

Once you have obtained the package name, execute the dpkg --remove command as per the example below:

sudo dpkg --remove <package_name>
Note:
The dpkg command is not the optimal method to install or remove a software package, as during the uninstallation process, dpkg may remove the specified package, but leave all of its associated dependencies on the system which may no longer function correctly.

Method #3: Uninstalling Software Set Up from the Source Code in Ubuntu

How to uninstall a program on Linux — Ubuntu? is often asked. To uninstall software that was set up from source code in Ubuntu, there are some important considerations:

  • You should not delete any source code you used to install the program.
  • You should ensure at installation, that there is a way to uninstall the program. A poorly configured program might not provide a way to uninstall the program, and then you’ll have to manually remove all the files installed by the software.
Note:
As an aside, try to limit installing software on a system using the configure, make,make install commands as most makefiles do not have or support an uninstallation process and as such, they are limited in this aspect. Always attempt to use a package manager that supports the tracking of install locations (.deb snap, etc) and let the package manager take care of removing and cleaning up uninstalled files and directories.

Before you can uninstall the software, you have to identify its files and directories. When you compiled and installed the software from source code, you most likely ran the configure, make, and make install commands. These commands have created and installed files all across your system. To find the files associated with the program, you have to locate the makefile, which contains the make uninstall command. The caveat is that not all source code installations provide a makefile with an uninstall command. It's up to the library's authors to provide that, some authors provide an uninstall target, others don't.

To start, open the terminal and navigate to the directory that the source code was extracted to. Once there, you need to look for the makefile that contains the uninstall command. Usually, the makefile is located in the same directory as the source code you downloaded. A common name for the file is Makefile or makefile (depending on the software you installed).

Once the makefile is located, open it and look for the uninstall command, which should be located at the end of the file. Copy the command and run it in the terminal. To run the uninstall command, open the terminal, and enter the command as follows:

sudo make uninstall

This command will search through the files and directories containing the software and remove them from your system. Typically, you should be able to uninstall the program by going to its extracted directory and using the command shown above.

You can also try to get a look at the steps used to install the software by running and then noting all the directories mentioned during the installation process and manually removing the entries:

sudo make -n install

Normally, you can use the makefile to delete the executable file and all the object files from the directory by running the following command:

sudo make clean

The make clean command usually cleans up the directories where the software was installed, however, it may not uninstall the package completely. Any dependencies needed or applied during the installation process may not be removed.

You can also use thecheckinstallcommand instead of just running sudo make install, as that will likely put files all over the system with no easy way of removing them if things go wrong. In the future, if you try to install a package that contains the same file as the software you are compiling, you will receive errors, and the software you originally compiled may stop working.

In fact, checkinstallcan keep track of files modified by any source install and not just a make install, so you can use it for any installation task outside apt, and it will keep track of the installation in the package manager.

We hope this section clarifies how to uninstall programs in Ubuntu when the source code is involved.

Method #4: Uninstalling Software Using the Git Uninstall Steps

Typically, Git simply clones an external repository to a local folder. If you used some form of non-standard prefix when configured so that a package has been installed under a specific hierarchy (for example, like under /opt/git/software/), then you can just recursively delete that folder's hierarchy.

If you've installed software using Git, you can use the git clean command to remove the application files and settings:

git clean -xfd

If Git was used, this step is very straightforward for how to uninstall a program on Linux.

Method #5: Uninstalling Software Using the Snapd Uninstall Steps

Snapd provides an easy method to install or uninstall software. From the command line, you can use the following commands to locate the software:

sudo snap list

The listoption provides an overview of all the installed snap packages. You can then use the remove option to remove the software. To remove a package installed using Snapd, use the following command:

sudo snap remove <package_name>

How to uninstall programs in Ubuntu using Snapd can be done easily as shown above.

Method #6: Uninstalling Software Using the Ubuntu Software Manager's Remove Software Functionality

The Ubuntu Software Manager provides a graphical interface for installing and uninstalling packages on your system. To uninstall software using the Ubuntu Software Manager, you should click on the icon in the Activities toolbar. This will open the Ubuntu Software Manager, where you can search for, install, and uninstall software from your computer.

Regarding how to uninstall a program on Linux for this use, in the list of applications, you would look up the software you want to uninstall, and then click the Remove button to uninstall it. If you’re short on space, you can use the clean command to remove downloaded archive files.

Method #7: Uninstalling Software Using the Flatpak Uninstall Steps

If an application was installed using Flatpak, you can begin by either searching for the application or listing all the applications installed via Flatpak:

sudo flatpak search
sudo flatpak list 

You can then use the uninstallation option of flatpak uninstall <package_name> by using the flatpak command along with the application package name to remove the installed software. Here is an example of the command syntax:

flatpak uninstall <package_name>

Method #8: Uninstalling Software via the AppImage Uninstall Steps

These applications run from the binary file without installation. To remove an AppImage package, simply delete the file.

Since the AppImage software is not installed in the normal sense of the word, you do not need to "uninstall" it. You simply have to delete the AppImage file, and the application will be removed (but this will not remove the data the application has created and/or downloaded). Also, you should remove menu entries by removing the desktop file from $HOME/.local/share/applications/.

Files and directories with names starting with a dot, like .example which are concealed, may need to be unhidden. You can probably find the unhide option in the settings of the file manager you use or in many file managers. You can usually accomplish this using the Ctrl + H keyboard sequence.

Method #9: Removing Files & Directories Manually

In some cases, running the make uninstall command may not completely remove all the files associated with the software. If this is the case, you may need to manually remove the directories containing the software.

To remove directories manually, use the rm command followed by the absolute path of the directory you want to remove. For example, if the directory you want to remove is located at /usr/local/bin/package, you would use the following command:

sudo rm -rf /usr/local/bin/package

This command will delete the directory and all its contents, including any subdirectories.

Conclusion

Several methods were covered for removing software packages from an Ubuntu system. Whether you prefer using the command-line interface or a graphical interface, Ubuntu provides various options for managing packages. Whether you're removing unnecessary packages to free up disk space or troubleshooting issues with a package, these methods will help you manage your Ubuntu system efficiently. These functions ensure your systems are kept clean and up to date.

If you need a new Ubuntu server for your next project, Liquid Web offers VPS Hosting, Cloud Dedicated Servers, and Dedicated Servers with the Ubuntu operating system.

Original Publication Date

This article was originally published in October 2022. It has since been updated for accuracy and comprehensiveness.

Avatar for Alison Gray

About the Author: Alison Gray

Alison Gray is currently an IT Project Manager at Liquid Web and has been with Liquid Web for nearly 10 years. In 2015, She earned her Bachelor's Degree in Media and Information from Michigan State University. In her free time, she loves spending time with her girlfriend and 3 kids. You can usually find her at a basketball court or some sort of sporting event. If the weather's right, she loves being outside in the yard finding some sort of yard work to do.

Latest Articles

Blocking IP or whitelisting IP addresses with UFW

Read Article

CentOS Linux 7 end of life migrations

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article