How to Purge Snap from Ubuntu: A Complete Guide for the Discerning User
So, you’ve decided to liberate your Ubuntu system from Snap. I understand. While Snap has its merits (security, cross-distribution compatibility), it’s not for everyone. Perhaps you crave the tighter control and perceived speed of APT packages, or maybe you’re simply not a fan of the resource consumption. Whatever your reason, removing Snap from Ubuntu is a perfectly legitimate desire. Let’s get straight to the point and then delve deeper into the nuances.
How to Remove Snap from Ubuntu?
The process involves several steps, and it’s crucial to follow them carefully to ensure a clean removal and avoid potential system instability. Here’s the roadmap:
- Remove all installed Snap packages: This is the foundational step. You can’t remove Snap while applications are still using it.
- Remove the Snapd daemon: This is the core service that manages Snap packages. Stopping and removing it is key.
- Purge Snap and associated files: This step cleans up any lingering configuration files or data directories.
- Prevent Snap from automatically reinstalling: This final touch ensures Snap doesn’t creep back onto your system after updates.
Now, let’s execute each of these steps with precision.
Step 1: Removing Installed Snap Packages
First, let’s list the Snap packages currently installed on your system. Open your terminal and type:
snap list This command will display a list of installed Snap applications, along with their version and other details. For each package, execute the following command:
sudo snap remove <package-name> Replace <package-name> with the actual name of the package you wish to remove. For example, to remove the “firefox” Snap package, you would type:
sudo snap remove firefox Repeat this process for every Snap package listed by snap list. You may encounter errors if a package is in use. In that case, close the application and try again, or use the --purge flag to force removal (though this should be used cautiously):
sudo snap remove <package-name> --purge After removing all your Snap applications, including the core Snapd components (if you have older versions of Ubuntu where these were initially installed via Snap), it’s time to move on to the daemon.
Step 2: Removing the Snapd Daemon
The Snapd daemon is the background service that manages Snap packages. To remove it, you first need to stop it. Execute the following commands:
sudo systemctl stop snapd sudo systemctl disable snapd sudo systemctl mask snapd These commands stop the service, prevent it from starting automatically on boot, and mask it to further prevent its unintentional activation. Now, remove the Snapd package itself:
sudo apt remove snapd This will remove the Snapd daemon and its associated files.
Step 3: Purging Snap and Associated Files
Even after removing the Snapd package, some configuration files and data directories might remain. To clean these up, use the following command:
sudo apt purge snapd This command removes configuration files as well. Next, remove the Snap directory:
sudo rm -rf ~/snap sudo rm -rf /var/snap sudo rm -rf /var/lib/snapd These commands remove the user-specific Snap directory, the system-wide Snap directory, and the Snapd library directory, respectively. Be extremely careful with the rm -rf command, as it permanently deletes files without confirmation. Ensure you are targeting the correct directories.
Step 4: Preventing Snap from Reinstalling
Ubuntu, in its relentless pursuit of Snap adoption, might try to reinstall Snap during system updates. To prevent this, create a preference file to prevent Snap from being installed via APT.
sudo apt update sudo apt install apt-transport-https sudo nano /etc/apt/preferences.d/no-snap.pref In the nano editor, paste the following lines:
Package: snapd Pin: release a=* Pin-Priority: -10 Save the file (Ctrl+O) and exit (Ctrl+X). This configuration tells APT to give Snap packages a very low priority, effectively preventing them from being installed unless explicitly requested.
Finally, hold the Snapd package:
sudo apt-mark hold snapd This ensures that the Snapd package will not be automatically updated or installed.
Frequently Asked Questions (FAQs) about Removing Snap from Ubuntu
Here are some common questions that arise when removing Snap from Ubuntu, answered with the precision and insight you’d expect from a seasoned Linux aficionado.
1. Why is removing Snap so complicated?
Canonical, the company behind Ubuntu, has deeply integrated Snap into the operating system. While this has benefits for them, it does make a complete removal more involved. The complexity stems from the need to remove not only the Snapd daemon but also prevent its automatic reinstallation.
2. Can I remove Snap without breaking my system?
Yes, absolutely. Following the steps outlined above carefully will remove Snap without causing system instability. However, it’s crucial to ensure you’ve removed all Snap packages before removing the Snapd daemon. Backing up your system before undertaking such changes is always a prudent measure, though unlikely to be necessary with these instructions.
3. What are the alternatives to Snap packages?
The primary alternative is APT packages, the traditional package management system for Debian-based distributions like Ubuntu. You can also use Flatpak, another containerized packaging system, or build applications from source code. Each has its pros and cons, but APT generally provides tighter integration with the system.
4. I removed Snap, but some applications are still installed. Why?
These applications are likely installed via APT or other package managers. Use apt list --installed or the relevant package manager’s command to identify and remove them.
5. I get an error message when trying to remove a Snap package. What should I do?
The error message usually indicates that the package is in use or has dependencies. Close the application and try again. If that doesn’t work, try the --purge flag with the snap remove command. Ensure you understand the implications before using --purge.
6. How can I check if Snap has been completely removed?
After following the steps above, run snap list. If no packages are listed and you get an error message indicating that the snap command is not found, Snap has been successfully removed. Also, verify that the directories /var/snap, /var/lib/snapd, and ~/snap do not exist.
7. Will removing Snap improve my system’s performance?
Potentially, yes. Snap packages can sometimes consume more resources than APT packages due to their containerized nature. Removing Snap and switching to APT alternatives may result in improved performance, especially on systems with limited resources. However, the actual impact will vary depending on your specific usage and hardware.
8. I reinstalled Ubuntu, and Snap is back! How do I prevent this?
You need to follow the steps to prevent Snap from reinstalling immediately after a fresh installation of Ubuntu. The preference file and apt-mark hold commands are essential for permanently preventing Snap from creeping back in.
9. What happens to Snap updates if I remove Snapd?
If you remove Snapd, you will no longer receive updates for any Snap packages. This is because Snapd is the service responsible for managing and updating them. This is one of the drawbacks, but the benefits of control often outweigh it.
10. Can I selectively remove some Snap packages and keep others?
Yes, you can. The snap remove command allows you to remove individual packages. You can choose to keep some packages installed via Snap while removing others. But keep in mind it will keep the Snapd daemon running.
11. I followed all the steps, but Snap is still showing up in my system. What did I miss?
Double-check that you have removed all Snap packages, including any core Snapd components. Ensure you have also correctly created the preference file and held the Snapd package. It’s also possible that you have a custom script or configuration that is reinstalling Snap.
12. Is it possible to revert back to using Snap after removing it?
Yes, it is. Simply install the snapd package using APT:
sudo apt update sudo apt install snapd This will reinstall the Snapd daemon and allow you to install Snap packages again. However, you’ll need to reinstall any Snap packages you previously removed.
Removing Snap from Ubuntu requires a bit of diligence, but it’s a perfectly achievable goal. By following these instructions carefully, you can reclaim control over your system and enjoy the benefits of a Snap-free environment. Good luck!
Leave a Reply