"sudo apt autoremove" - Remove Unneeded Packages

This section provides a tutorial example on how to use the 'apt autoremove' command to remove all packages that are no longer needed on Ubuntu computer.

After using your Ubuntu computer for a while, you may noticed that the "apt install" command provides you a no-longer-required package list in the output as shown below.

herong$ sudo apt install smem   

Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  ca-certificates-mono cli-common libgdiplus libglib2.0-cil libgtk2.0-cil
  libllvm7 libllvm9 libmono-addins-gui0.2-cil libmono-addins0.2-cil
  libmono-cairo4.0-cil libmono-corlib4.5-cil libmono-i18n-west4.0-cil
  ...
Use 'sudo apt autoremove' to remove them.
...

The no-longer-required package list represents old packages that were installed as part of the original Ubuntu distribution or as dependencies of manually installed packages, and got obsolete after software updates. You can safely remove all of them using the suggested "sudo apt autoremove" command.

herong$ sudo apt autoremove

Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  ca-certificates-mono cli-common libgdiplus libglib2.0-cil libgtk2.0-cil
  libllvm7 libllvm9 libmono-addins-gui0.2-cil libmono-addins0.2-cil
  libmono-cairo4.0-cil libmono-corlib4.5-cil libmono-i18n-west4.0-cil
  libmono-i18n4.0-cil libmono-posix4.0-cil libmono-security4.0-cil
  libmono-sharpzip4.84-cil libmono-system-configuration4.0-cil
  libmono-system-core4.0-cil libmono-system-drawing4.0-cil
  libmono-system-security4.0-cil libmono-system-xml4.0-cil
  libmono-system4.0-cil mono-4.0-gac mono-gac mono-runtime 
  mono-runtime-common mono-runtime-sgen
0 to upgrade, 0 to newly install, 27 to remove and 6 not to upgrade.
After this operation, 158 MB disk space will be freed.
Do you want to continue? [Y/n] Y 

(Reading database ... 201429 files and directories currently installed.)
Removing ca-certificates-mono (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-addins-gui0.2-cil (1.0+git20130406.adcd75b-4) ...
Removing libmono-addins-gui0.2-cil from Mono
Removing libmono-addins0.2-cil (1.0+git20130406.adcd75b-4) ...
Removing libmono-addins0.2-cil from Mono
Removing libgtk2.0-cil (2.12.40-2) ...
Removing libgtk2.0-cil from Mono
Removing libmono-system-drawing4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libgdiplus (4.2-2) ...
Removing libglib2.0-cil (2.12.40-2) ...
Removing libglib2.0-cil from Mono
Removing libllvm7:amd64 (1:7-3~ubuntu0.18.04.1) ...
Removing libllvm9:amd64 (1:9-2~ubuntu18.04.2) ...
Removing libmono-cairo4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-i18n-west4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-i18n4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-system-core4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-posix4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-sharpzip4.84-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing cli-common (0.9+nmu1) ...
Removing libmono-system-configuration4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-system-security4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-system4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-system-xml4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-corlib4.5-cil (4.6.2.7+dfsg-1ubuntu1) ...
Removing mono-runtime (4.6.2.7+dfsg-1ubuntu1) ...
Removing mono-runtime-sgen (4.6.2.7+dfsg-1ubuntu1) ...
Removing mono-runtime-common (4.6.2.7+dfsg-1ubuntu1) ...
update-binfmts: warning: no executable /usr/bin/cli found, 
  but continuing anyway as you request
Removing mono-gac (4.6.2.7+dfsg-1ubuntu1) ...
Removing mono-4.0-gac (4.6.2.7+dfsg-1ubuntu1) ...
Removing libmono-security4.0-cil (4.6.2.7+dfsg-1ubuntu1) ...
dpkg: warning: while removing libmono-security4.0-cil, 
  directory '/usr/lib/mono' not empty so not removed
dpkg: warning: while removing libmono-security4.0-cil, 
  directory '/etc/mono/certstore' not empty so not removed
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for ca-certificates (20230311ubuntu0.18.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.

Running hooks in /etc/ca-certificates/update.d...
done.
Updating Mono key store
/etc/ca-certificates/update.d/mono-keystore: 10: 
  /etc/ca-certificates/update.d/mono-keystore: 
  /usr/bin/cert-sync: not found
done.
Processing triggers for mime-support (3.60ubuntu1) ...

Rerun the command to double-check.

herong$ sudo apt autoremove 

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 6 not to upgrade.

Table of Contents

 About This Book

 Introduction to Ubuntu Systems

 GNOME - Desktop Interface and Environment

 Shell - The Command-Line Interpreter

 Process Management

 Memory Management

 Files and Directories

APT (Advanced Package Tool)

 What Is APT

 "apt list" - List Software Packages

 "apt show" - Show Software Package Details

 "sudo apt install/remove" - Install/Remove Package

"sudo apt autoremove" - Remove Unneeded Packages

 Manage "apt" Package Repositories

 APT Configuration Settings and Overrides

 APT Package Archives and Metadata

 Network Connection on Ubuntu

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Administrative Tasks

 References

 Full Version in PDF/EPUB