FUNDAMENTALS A Complete Guide for Beginners
Dependencies specify some prerequisite packages that are essential for a particular package to work as intended. Often, you may not be using an installed package because you don’t need it anymore. Besides, sometimes you may need to install a package to do a one-time task or solve a specific problem. In these cases, you can remove the package to free your system memory. In this tutorial, I’ll demonstrate different ways that you can use to remove packages and dependencies in Ubuntu distributions.
To remove packages and unused dependencies, check the following methods:
- Using apt or apt-get command: apt autoremove <package_name>
- Using snap command: snap remove [package_name]
- Using dpkg command: dpkg -r <package_name>
- Using synaptic package manager
- Using GNOME software
Key Takeaways
- Removing the DEB package in Ubuntu.
- Inspecting dependencies regarding TeamViewer and VLC uninstallation.
- Uninstalling unused dependencies during the removal.
Requirements
- System running on Ubuntu.
- Sudo privileges to use the core functionality of package managers.
- Synaptic Package Manager installed in your Ubuntu system.
- GNOME Software installed in your Ubuntu.
Process Flow Chart
[Distro Used Throughout the Tutorial: Ubuntu 22.04.1 LTS]
5 Methods to Remove Packages and Dependencies in Ubuntu
In Linux, you can remove a package in two basic types. The first one is to remove a package with all its dependencies like config files, libraries, and binaries using CLI. Secondly, you can remove a package using the package manager in GUI. In this guide, I’ll show you five different approaches you can use in both cases in your Ubuntu system.
A. Remove Packages and Dependencies in Ubuntu With CLI
CLI(Command Line Interface) is a command line tool for Linux where you can type and execute commands directly. To remove a package and its dependencies using CLI, built-in package management tools are used. In the first three methods, I’ll show you the use of different package management tools in CLI to remove a package and dependencies in Ubuntu.
Method 01: Using “apt” or “apt-get” to Remove Packages and Dependencies
APT (Advanced Package Tool) is a powerful package management system used in Debian-based Linux distributions, including Ubuntu. It simplifies software removal as well as installation by handling dependencies automatically.
To remove an unused package with all dependencies, APT offers the following syntax:
sudo apt autoremove <package name>
Now, follow these steps to remove TeamViewer with all dependencies using APT:
Steps to Follow >
➊ Open the Ubuntu terminal. You can press CTRL+ALT+T.
➋ Run the following command:
sudo apt autoremove teamviewer
➌ Enter user password if required.
➍ Type Y when the confirmation prompt appears.
➎ Press ENTER.By the above command, APT will remove TeamViewer from the system with all unused dependencies. However, you can also use the apt-get command to remove packages and dependencies using the following syntax:
sudo apt-get autoremove <package name>
These commands removes dependencies but keeps the configuration files. However, if you want to remove the configuration files also, you have to use the below command:
sudo apt autoremove --purge <package name>
Method 02: Using “snap” to Remove Package and Dependencies
Snaps in Ubuntu are designed to be self-contained and don’t have explicit dependencies on other packages like traditional package management systems such as APT. This means that when you remove a snap package, it should not affect other parts of your system, and there are no dependencies to manage. Anyway, to remove a snap package and its associated dependencies which are contained within the snap package itself, you can follow the below steps:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ Run the below command to list all snap packages installed in the system:
snap list
- snap: Command to manage Snap packages.
- list: Displays a summary of snaps installed in the current system.
➌ Run this command to remove vlc snap:
snap remove vlc
- remove: Command to remove Snap packages.
- vlc: Snap package name that you want to remove.
➍ Enter user password in the authentication box.
➎ Click on Authenticate.After that, some quick message will be shown in the terminal. Finally, the terminal will show a confirmation message of removal like this:This indicates that the removal of vlc snap is successful.
Method 03: Using “dpkg” to Remove Package and Dependencies
DPKG (Debian Package Manager) is a low-level package manager in Debian-based Linux distributions that provides dpkg package management tool. Like installing, this tool can also remove packages from Ubuntu. Becoming a flexible package management tool, dpkg provides the facility to remove packages with some selective dependency packages. So, if you have the .deb file of the package you want to remove with dependencies, you can use dpkg by following these steps:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ Change the working directory to where the .deb file is present. In my case, it is in the Downloads folder.
cd ~/Downloads/
- cd: Command to Change D
- ~/Downloads/: Absolute path of Downloads
➌ Check the file presence using this command:
ls
- ls: Lists all the files and folders in the current directory.
sudo dpkg -I teamviewer_15.43.7_amd64.deb | grep Depends | sed 's/Depends: //' | tr ',' '\n' | sed 's/^ *//'
- sudo: Enables administrative permissions.
- dpkg: Calls DPKG package manager.
- -I: Option is used to display information about the package
- grep: Command to search lines in the output.
- | (Piping Symbol): Used to transfer the output of a command as the input of another command.
- sed ‘s/Depends: //’: Here, the sed command is used to remove the “Depends: ” prefix from each line that contains the word “Depends“.
- tr ‘,’ ‘\n’: This command replaces commas (,) with newline characters (\n).
- sed ‘s/^ *//’: This sed command removes any leading spaces of each line.
apt show <package name>| grep Depends | sed 's/Depends: //' | tr ',' '\n' | sed 's/^ *//'
Replace <package name> with the actual name of the package you want to remove.
The output shows all dependencies of TeamViewer in a list. You can manually select which dependencies you want to remove with TeamViewer. Suppose, I want to remove libminizip1 along with TeamViewer. Follow the next step to do that.
➎ Write the following command on the terminal:
sudo dpkg -r teamviewer libminizip1
➏ Enter the user password if asked.
➐ Press ENTER.
➑ After removing dependencies, you can remove the software package with the same syntax:
sudo dpkg -r <package name>
In this case, <package name> will be replaced with teamviewer.
B. Remove Packages and Dependencies in Ubuntu With GUI
In Ubuntu, you can manage software packages using GUI (Graphical User Interface) tools. The most commonly used GUI package management tools are:
- Synaptic Package Manager
- Ubuntu GNOME Software
Now in the following two methods, I’ll show you how to use these tools of GUI package management to remove a package and dependencies in Ubuntu.
Method 04: Using Synaptic Package Manager to Remove Package and Dependencies in Ubuntu
Synaptic Package Manager, often called “Synaptic“, is a GUI (Graphical User Interface) package management tool for Debian-based Linux distributions. It can handle dependencies and other package management tasks such as installing, removing and updating packages effectively. Follow these steps to remove packages and dependencies using Synaptic in Ubuntu:
Steps to Follow >
➊ Open Synaptic Package Manager from the Show Applications section.➋ Type the user password in the authentication window and click Authenticate.➌ Click on the Search icon at the top right corner.
➍ Type teamviewer in the search box.
➎ Click on Search.A list of packages that have “teamviewer” in their name will appear.
➏ Right-click on the package and select Mark for Complete Removal.After that, Synaptic Package Manager will remove TeamViewer completely from the system.
Method 05: Using Ubuntu Software to Remove Package and Dependencies in Ubuntu
Ubuntu Software Center, also known as GNOME Software, provides a graphical interface for installing and removing software on Ubuntu. When you use it to uninstall a software package, it will typically handle the removal of any dependencies that were automatically installed alongside the package. Here’s how to do it:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ Run this command:
gnome-software
➌ Press ENTER.
➍ Click on Installed.➎ Scroll down to the package you want to remove and click Uninstall.Then, GNOME-Software will remove VLC and its dependencies from your Ubuntu.
Comparative Analysis of Methods
I’ve shown a total of five ways to remove packages and dependencies in Ubuntu. You might be confused to decide which one suits you the best. Here’s a comparison between the methods provided to give you an overview of the pros and cons.
Methods | Pros | Cons |
---|---|---|
Method 1 |
|
|
Method 2 |
|
|
Method 3 |
|
|
Method 4 |
|
|
Method 5 |
|
|
If you are comfortable with CLI and want to remove a package and all its dependencies automatically, you can use “Method 1″. However, if you are not comfortable with CLI, you can use “Method 4″ in this situation. In case, you have a .deb file of a package and you want to remove it and its dependencies, you should follow “Method 3″. Moreover, use “Method 2″ to remove a Snap package. “Method 5″ is suitable for removing a package that was installed via Ubuntu Software.
Common Challenges That May Arise
Although some of the package managers handle missing dependencies in Ubuntu automatically, challenges may arise sometimes. Some common challenges you might encounter and how to address them are listed below.
- Unintended Removal: Be cautious when using commands like apt autoremove or apt remove with packages that have a large number of dependencies.
- Configuration Files: Removing configuration files with apt remove are often retained by default. If you want to remove them, you need to use apt purge or apt –purge remove.
- Dependency Conflicts: Sometimes, removing a package can result in dependency conflicts if multiple packages share the same dependencies.
- Dependencies Marked as Manually Installed: Packages installed as dependencies are marked as “automatically installed” by default. Using apt autoremove can remove these automatically installed packages, it can lead to the removal of packages you might still need.
- System Unstable: If you’re unsure about the consequences of removing a package and its dependencies, this may lead to an unstable system.
Install GNOME Software in Ubuntu
If you don’t have GNOME Software installed, first you have to install it to use. To install GNOME Software in your Ubuntu, follow the below steps:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ Run this command:
sudo apt install -y gnome-software
- sudo: Enables administrative permissions.
- apt: Calls APT package management tools.
- install: Command for installing a package using apt.
- -y: Answers YES automatically to any confirmation prompt.
- gnome-software: Package name of GNOME software.
➌ Enter the user password if asked.
➍ Press ENTER.That’s it. Now apt will install GNOME Software in your Ubuntu.
Conclusion
To minimize the challenges regarding dependency removal, it’s crucial to carefully review the consequences before proceeding with any removal operation. Understanding the dependencies and potential impacts on your system is key to the successful removal of packages and dependencies in Ubuntu. It’s better to use a virtual environment before removing crucial packages that may be used by the system itself.
People Also Ask
Related Articles
- How To Check Package Dependencies in Linux [3 Easy Ways]
- How to Install Dependencies Using dpkg? [Easiest Solution]
- How to Install Missing Dependencies in Ubuntu? [4 Methods]
- Install Dependencies Automatically in Ubuntu [3 Exclusive Methods]
- How to Install RPM Package With Dependencies? [3 Methods]
- 2 Ways to Install RPM Without Dependencies in Linux
- How to Check RPM Reverse Dependencies in Linux? [4 Methods]
- [Solved] RPM Failed Dependencies Error in RedHat
- 2 Methods to Install YUM Packages with Dependencies
- Remove Packages without Dependencies Using Yum [2 Methods]
- [Solved] The Following Packages Have Unmet Dependencies Error
- How to Check APT Dependency Tree in Linux? [4 Methods]
<< Go Back to Dependencies in Linux | Package Management in Linux | Learn Linux Basics