Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Uninstall or Remove Packages in Ubuntu

List installed packages and remove them with apt, apt-get, purge, autoremove and snap.

VPS and Cloud Servers2 min read14 screenshots

List installed packages

dpkg --list
Listing the installed packages with dpkg
apt list --installed
Listing the installed packages with apt

Show the 20 biggest packages:

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
The biggest installed packages

remove

remove deletes the program but keeps its configuration files.

sudo apt remove package-name

Example:

sudo apt remove firefox
Removing Firefox

purge

purge deletes the program and its configuration files.

sudo apt purge package-name
Purging a package
sudo apt purge firefox

autoremove

After a removal, some packages that were installed only as dependencies are no longer needed:

sudo apt autoremove
Removing the unneeded dependencies

Remove them and their configuration files:

sudo apt autoremove --purge
Autoremove with purge

Read the list before you confirm.

apt-get

apt-get works the same way:

sudo apt-get remove firefox
Removing a package with apt-get
sudo apt-get purge firefox
Purging a package with apt-get

Snap packages

List the snaps:

snap list
Listing the snap packages

Remove one:

sudo snap remove package-name
Removing a snap package
Note: On current Ubuntu versions apt install firefox installs a snap, so use snap remove firefox to remove it.

Remove old kernels

First see the kernel you use:

uname -r
The running kernel version

List the installed kernels:

dpkg --list | grep linux-image
Listing the installed kernels

Remove an old one (never the one you run):

sudo apt remove --purge linux-image-5.15.0-91-generic
Removing an old kernel

sudo apt autoremove also removes old kernels in most cases, and Ubuntu keeps the last two.

Clean the package cache

sudo apt clean

Quick recap

  • apt remove keeps the config, apt purge deletes it too.
  • Run apt autoremove to clear unused dependencies.