So, you've got a shiny new Ubuntu 22.04 server. It's powerful, it's reliable, and it's... full of stuff you didn't ask for. If you're a developer, a sysadmin, or just a Linux enthusiast who likes a clean, lean machine, you might have noticed that Canonical has been pushing its Snap package manager pretty hard. And while Snaps have their place, they're not for everyone.
If you're ready to take back control of your server and build a system that's truly your own, you've come to the right place. In this guide, we'll walk you through the process of completely removing Snap and other Canonical-specific features from your Ubuntu 22.04 server. Think of it as a digital detox for your machine.
Why Bother?
You might be wondering, "What's the big deal? Why not just leave Snap alone?" And that's a fair question. For some, Snap is a convenient way to install software. But for others, it's a source of frustration. Here are a few reasons why you might want to give Snap the boot:
- Performance: Snaps can be slower to start up than their traditionally installed counterparts. On a server, where every millisecond counts, this can be a deal-breaker.
- Control: Snaps are designed to be self-contained and isolated. While this is great for security, it can also make it harder to customize and configure your applications.
- Bloat: A default Ubuntu Server installation comes with a handful of Snaps that you might not need or want. Removing them can free up disk space and simplify your system.
- Philosophy: Some users simply prefer the traditional
apt
package manager and the vast repositories of.deb
packages that have been the backbone of Debian and Ubuntu for years.
The Great Escape: A Step-by-Step Guide
Ready to liberate your server? Grab your favorite beverage, open up a terminal, and let's get to work.
Step 1: See What You're Dealing With
First things first, let's take a look at the Snaps that are currently installed on your system. Run the following command:
snap list
This will give you a list of all the Snaps that are currently taking up space on your server.
Step 2: The Purge
Now it's time to get rid of them. You'll need to remove each Snap individually. It's best to start with the applications and then move on to the core Snaps.
sudo snap remove --purge lxd
sudo snap remove --purge core20
sudo snap remove --purge snapd
The --purge
flag is important here. It tells Snap to remove not just the application, but also all of its data and configuration files.
Step 3: Banish the Snap Daemon
With the Snaps themselves gone, it's time to deal with the snapd
daemon, the background service that manages Snaps.
sudo systemctl disable snapd.service
sudo systemctl disable snapd.socket
sudo systemctl disable snapd.seeded.service
sudo systemctl mask snapd.service
These commands will stop the snapd
service from running and prevent it from starting up automatically when you reboot your server.
Step 4: The Final Blow
Now for the coup de grâce. Let's remove the snapd
package itself.
sudo apt autoremove --purge snapd
This will remove the snapd
package and any other packages that were installed as dependencies.
Step 5: Clean Up the Crime Scene
Even after purging snapd
, there might be a few leftover files and directories. Let's get rid of them.
rm -rf ~/snap
sudo rm -rf /var/cache/snapd/
Don't Let It Come Back: Preventing Snap's Return
You've done it! You've successfully removed Snap from your server. But our work isn't done yet. We need to make sure that Snap doesn't sneak back in when you're not looking.
Step 1: Put a Lock on It
We can use a feature of apt
called "pinning" to prevent snapd
from being installed in the future. Create a new file in /etc/apt/preferences.d/
called nosnap.pref
:
sudo nano /etc/apt/preferences.d/nosnap.pref
And add the following lines to the file:
Package: snapd
Pin: release a=*
Pin-Priority: -1
This tells apt
to give snapd
a negative priority, which means it will never be installed automatically.
Bonus Mission: Silencing the Chatter
While we're at it, let's get rid of a few other Canonical-specific features that you might not want on your server.
Disable the "Message of the Day" News
The "message of the day" that you see when you log in to your server can sometimes contain promotional messages. To disable this, edit the /etc/default/motd-news
file:
sudo nano /etc/default/motd-news
And change ENABLED=1
to ENABLED=0
.
Mute the Ubuntu Pro Ads in apt
The apt
command can also show messages about Ubuntu Pro. To disable these, you can use the pro
command:
sudo pro config set apt_news=false
Or, for a more forceful approach, you can remove the ubuntu-advantage-tools
package altogether:
sudo apt-get --assume-yes --purge remove ubuntu-advantage-tools ubuntu-pro-client
The Victory Lap
Congratulations! You've successfully liberated your Ubuntu server from the clutches of Snap and other Canonical-specific features. You now have a lean, clean machine that's ready for whatever you want to throw at it.
So go ahead, install your favorite software with apt
, customize your configurations to your heart's content, and enjoy the feeling of having a server that's truly your own. You've earned it.
Liberate Your Ubuntu Server: A Guide to Ditching Snap and Friends
Ready to ditch Snap? This guide shows you how to completely remove Snap and other Canonical features from your Ubuntu 22.04 server for a leaner, faster machine.