All Posts programming [guide] How to completely remove Snap from Ubuntu ?

[guide] How to completely remove Snap from Ubuntu ?

· 531 words · 3 minute read

I have a laptop with Microsoft Windows 11 Pro installed and a WSL with the default Ubuntu distribution. It is preconfigured with Snap package manager. But I am not using Snap in Ubuntu WSL. So I feel the need to remove/purge it.

info
I am not a snap-hater. I publish my gobrew tool as a snap. I already have another laptop with Ubuntu 24.04.3 LTS and many programs installed via snap there. I just not need it on this WSL Ubuntu.

To completely remove Snap from an Ubuntu distribution in WSL, you must first remove all existing snap packages, then uninstall the snapd daemon, and finally remove leftover directories.

Step 1: List and Remove Snap Packages 🔗

First, list all installed snap packages to identify what needs to be removed.

Open your Ubuntu terminal in WSL and run:

snap list

For each package listed, remove it individually.

info
Remove any snap package other than core or snapd. After removing all other snap packages, remove core packages and snapd too.

For example, if firefox is listed:

sudo snap remove --purge firefox

You may need to disable services for certain snaps (like firefox) if you encounter “read-only file system” errors.

sudo systemctl stop var-snap-firefox-common-host\\x2dhunspell.mount
sudo systemctl disable var-snap-firefox-common-host\\x2dhunspell.mount

Then try removing the package again

sudo snap remove --purge firefox

Step 2: Remove the snapd Daemon 🔗

Once all individual packages are removed, you can remove the main snapd package itself.

Stop and disable the snapd services:

sudo systemctl stop snapd.service
sudo systemctl disable snapd.socket
sudo systemctl disable snapd.service

Purge the snapd package using apt:

sudo apt purge snapd -y

You can also remove the snap plugin for the software store if installed:

sudo apt purge gnome-software-plugin-snap -y

Clean up any unused dependencies:

sudo apt autoremove -y

Step 3: Remove Leftover Directories 🔗

Remove any remaining directories to ensure no traces of snap are left.

Run the following commands:

rm -rf ~/snap
sudo rm -rf /snap
sudo rm -rf /var/snap
sudo rm -rf /var/lib/snapd
sudo rm -rf /var/cache/snapd
sudo rm -rf /usr/lib/snapd

Step 4: Prevent Snap from Reinstalling 🔗

To prevent snapd from being automatically reinstalled by other packages in the future, create a preference file to give it a negative priority.

Create the file using a text editor (like nano):

sudo nano /etc/apt/preferences.d/no-snap.pref

Add the following lines to the file and save it ( Ctrl + O, then ↵ Enter, then Ctrl + X if using nano):

Package: snapd
Pin: release a=*
Pin-Priority: -10

Step 5: Update and Reboot 🔗

Update your package lists:

sudo apt update

Reboot your WSL instance to finalize all changes. In a Windows Command Prompt or PowerShell, run:

wsl --shutdown

Reopen your Ubuntu instance in WSL. Snap should now be completely removed.

info
If you prefer running scripts, here is a script that automates the removal of snap package manager: https://github.com/giggio/dotfiles/blob/main/remove-snap-from-wsl.sh

I hope you enjoyed reading this post as much as I enjoyed writing it. If you know a person who can benefit from this information, send them a link of this post. If you want to get notified about new posts, follow me on YouTube , Twitter (x) , LinkedIn , and GitHub .