We already saw how to create Debian packages, now we’ll see how to remove them. Removing packages in Debian or Ubuntu Linux from the console is very easy, your user must be in the sudoers or you’ll need root access.
Identify the package to delete: dpkg –list
dpkg –-list will show you a list of packages, in this case the distribution used for the image is Kali Linux.
Let’s remove Skype using apt-get and dpkg commands:
Removing skypeforlinux using apt-get
For Ubuntu the correct method to remove packages through the console is:
The parameter “–-remove” will remove installation files while keeping configuration data, by adding “–-purge” we instruct to remove configuration files too.
Removing skypeforlinux using dpkg
We can remove Skype replacing apt-get with dpkg like in the following example:
We can use also
(Where “packagename” is replaced by the package’s name.)
Removing Broken Packages
In order to remove broken packages, or packages which weren’t fully installed we will run
sudo apt-get -f install
dpkg –configure -a
Details:
clean: Removes cache of programs older than the installed.
autoremove: Removes unnecessary files, like dependencies which are not longer needed.
-f / –fix-broken install: Fix broken dependencies, correct possible package corruption problems. We’ll see this option deeply later.
Troubleshooting
For different reasons a package’s removal, or a package’s installation may return errors. The most popular causes for such errors are old programs, partially installed packages, corrupted packages, outdated repositories at etc/apt/sources.list, etc. The following commands and their order are basic to solve initial problems in the packages manager. If you are experiencing problems installing or uninstalling software on Ubuntu 12.04 or higher or Debian, run the following commands:
#dpkg –-configure -a
#apt-get -f install
#apt-get clean
apt-get update: Updates the packages’ list in the repositories.
dpkg –configure -a: This command checks for dependency problems to fix.
apt-get -f install: Another command to fix dependency problems.
apt-get autoclean: clean unnecessary dependencies.
Check if packages are being held by the packages manager
To check if the installer holds packages pending of installation run:
This will show you held packages. If listed, to remove packages run: