Join my Laravel for REST API's course on Udemy 👀

Uninstalling packages on Ubuntu with `apt`

April 15, 2021  ‐ 2 min read

Everyone in a while it doesn't hurt to remove some of the clutter on your Linux system. With the command apt remove <package, ...> you can remove packages from your system. Besides remove you have the apt purge <package, ...> command available to you as well, which removes configuration settings for that package as well.

Removing a package from the command line with apt goes as follows:

$ sudo apt remove pipenv
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  ipset libipset13 python3-appdirs python3-distlib python3-filelock python3-importlib-metadata python3-more-itertools python3-virtualenv python3-virtualenv-clone python3-zipp xsltproc
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  pipenv
0 upgraded, 0 newly installed, 1 to remove and 24 not upgraded.
After this operation, 12,8 MB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 267202 files and directories currently installed.)
Removing pipenv (11.9.0-1) ...
Processing triggers for man-db (2.9.1-1) ...

One interesting line you may see in the commands output is "The following packages were automatically installed and are no longer required". The packages that are listed below are packages which were installed as a dependency of the package we removed which are no longer necessary now. They are orphaned so to say.

To remove these former dependencies you run the command that is suggested in the output as well:

$ sudo apt autoremove