62

I've just installed Ubuntu 18.04. After a few minutes I noticed my bandwidth is remarkably low. I installed nethogs and realized /usr/lib/snapd/snapd is consuming my internet.

Questions:

  1. How can I disable it? It really stops me from using the internet.
  2. Can I disable snap package system when installing Ubuntu?

Thanks a lot,

Shahin
  • 743
  • 1
    I assume that it is important to preserve a way to get security updates for existing snap packages. Leaving the system without an automated security upgrade procedure would be taking a huge step backwards. But of course there needs to be a way to manage overuse of bandwidth. – nealmcb Sep 29 '18 at 21:13
  • 2
    this script will start snap service, do a refresh and disable it again : https://gist.github.com/rubo77/15366925051dd214b18c306f9389a573 – rubo77 Jan 13 '20 at 18:10
  • @karel what should be used to decide the direction? The other question seems to have answers to the question "how to stop snapd from auto-updating" while this one only answers "how to stop snapd", which is why I voted to close this one. (and the main answer to this one doesn't even work) – Merlijn Sebrechts Aug 14 '20 at 19:37
  • 2
    It would help if at least the snap daemon would ask me if I want to update now because updating an app e.g. Chrome that is currently running usually lets that app crash. Sometimes I am getting a message "New Software Updates available – Install/View/Cancel" but when I click "View", I can not see updates and they usually just have been installed automatically. Really annoying. – w-sky Mar 04 '21 at 10:07
  • 7
    @nealmcb the real step backwards is for Ubuntu to go the Microsoft way and force-install stuff on our computers without allowing even advanced users to opt-out. What's worse, is that while Microsoft's forced updates are an annoyance, Snap's auto-updates are a SECURITY RISK because they auto-update from any arbitrary vendor. the fact that I trust some vendor enough to install their app today (possibly after some vetting), does not mean I necessarily will trust them tomorrow. you don't think that auto-updates themselves can be insecure? tell that to the customers of Solar Wind. – obe Jun 19 '21 at 12:41
  • 1
    Very well put, @obe! So many competing priorities.... – nealmcb Jul 25 '21 at 16:41

7 Answers7

49
  1. You can disable autostart for the service by clicking on the start button then search for "Startup Applications" and change the setting like this.


  1. If these answers did't help out you may do next:

    sudo systemctl mask snapd.service - Completely disable the service by linking it to /dev/null; you cannot start the service manually or enable the service.

    sudo systemctl unmask snapd.service - Removes the link to /dev/null and restores the ability to enable and or manually start the service


If you will need update a snap program you can unmask and start the service, then use command snap refresh

rubo77
  • 32,486
  • 3
    this should be considered the real answer. the "official" answer is just giving the asker the runaround. – Emandudeguy Jul 26 '18 at 08:02
  • 1
    The answer should show how to open that services dialog – doug Jul 28 '18 at 16:43
  • 1
    Wouldn't this disable security updates, leaving the system vulnerable the next time a new vulnerability isn't patched? – nealmcb Sep 29 '18 at 21:11
  • On my Ubuntu Budgie 18.10 distro, I found the setting by clicking on the start button then search for "Startup Applications". However, this does not solve the problem. The auto update continues. – Martin Andersson Nov 12 '18 at 23:27
  • 13
    Security updating is to use 1Mb/s for a couple of seconds each now and then (possibly while the screen is locked), not 1Mb/s for five minutes while I'm gaming, this is a plain abuse of my internet connection. Before doing a couple of lsof I thought it was some weird malware. – Avio Feb 15 '19 at 20:51
  • In the Startup Applications, I see no snap helper. But the second solution worked fine, thx – rubo77 Jan 13 '20 at 16:59
  • 2
    If I mask sanpd, will my already installed snap applications crash OR wont work in the next boot? I want to disable auto updates. But still want to use snap applications – Rumesh Madhusanka Apr 20 '20 at 03:31
  • 1
    @RumeshMadhusanka I tested mask / stop / disable do not cause crash, even though the snap.service is not in HTOP, my Opera Browser snap is still working. (Sadly, you need to start again manually to load snaps again, after reboot or during the same session.) – prosody-Gabe Vereable Context Sep 08 '21 at 03:00
  • 1
    So that's why my data was ruined so fast since the last half year I've been depending on a mobile data plan!!! Thank you so much Snap devs! Now tell me that I missed the heads-up for it, meh! – ecv Nov 18 '21 at 15:15
  • This did not stop the services. According to the systemctl man page, run the command with: The --now option may be used to ensure that the units are also stopped.``` The manual also suggests thatmask` may only be until reboot but on reboot, the service IS disabled correctly. – Tony Barganski Mar 23 '22 at 17:18
43

Snap packages are a good way to get access to much more software than before. You can now get as snap packages Skype, LibreOffice latest, GIMP latest, all JetBrains IDEs or even games.

All these are installed using the Ubuntu Software application and it's not necessary to use the command line.

The important question for you is this, do you really need to disable snap packages?

To temporarily disable snap packages (until reboot or if you run with start):

sudo systemctl stop snapd.service

To permanently disable snap packages:

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

To reenable snap packages:

sudo systemctl reenable snapd.service
sudo systemctl start snapd.service
Simos
  • 884
  • 5
    Answer does not work: Merely disabling snapd is not enough. My system started snapd after reboot nevertheless. – johannes_lalala Jan 02 '20 at 22:47
  • 10
    disabling didn't work, after reboot it is automatically re-enabled. you have to mask the service with sudo systemctl mask snapd.service to make it reboot-safe (stop it manually if you don't want to reboot) – rubo77 Jan 13 '20 at 17:04
  • 2
    Firefox and Chromium don't work any more when I disable snapd : error: cannot communicate with server: Post http://localhost/v2/snapctl: dial unix /run/snapd-snap.socket: connect: no such file or directory ERROR: not connected to the gnome-3-38-2004 content interface.. Is there a way to disable snapd and still have an internet browser? – Thomas May 09 '23 at 07:47
16

You can stop and mask your snapd service with:

systemctl mask snapd.service
systemctl stop snapd.service

And then use this script, which will give you the possibility to update your snaps easily ever still:

#!/bin/bash

this script unmasks and starts the snapd service, do a refresh and disables it again

set -x systemctl unmask snapd.service systemctl start snapd.service systemctl status --no-pager snapd.service snap refresh systemctl mask snapd.service systemctl stop snapd.service sleep 2 kill -9 $(pgrep snapd)

Put it in /usr/local/sbin/snap-update and give it executable rights with chmod +x.

Then you can just run:

sudo snap-update

I created a gist for it here that also deletes the old snaps, after new ones are installed.

Note: If you run the apt auto updater and there is an update to a package that is managed by snapd, it will hang if snapd is masked, so remember to unmask snapd in that case and start apt upgrade again

rubo77
  • 32,486
5

I tried determining the pid for /usr/lib/snapd/snapd, using sudo nethogs wlp4s0.
Then killed this process using sudo kill -9 pid_of_the process.
Then disabled this process using sudo systemctl disable snapd.service.
Since then, i'm living a peaceful life. My data usage remains under control as well.

taurus05
  • 151
  • 1
  • 3
  • 3
    +1 for nethogs, nice tool! But for stopping snapd you can use simply pgrep: one line: sudo kill -9 $(pgrep snapd); sudo systemctl stop snapd.service; sudo systemctl mask snapd.service – rubo77 Jan 13 '20 at 18:02
2

You can change update time of snap to, say, Monday 12 a.m. like this:

sudo snap set system refresh.timer=mon,12:00

Then you have to refresh it

sudo snap refresh

As mentioned you can also temporarily disable updates:

sudo systemctl stop snapd.service
Zanna
  • 70,465
1

snaps updates are controlled by the app developers if you don't want a particular snap to update you could ask the developer to create a "static" channel which they simply don't update, updates would then be a simple matter of switching channels with sudo snap refesh <snap> --channel=<new-version>

i see that nextcloud approaches it this way; they appear to have a channel for version 12, among others, which hasn't seen an update since 2018

Fuseteam
  • 383
1

I see that disable service is not enough to stop the service. for me, I needed to disable snapd.socket

sudo systemctl stop snapd.socket
sudo systemctl disable snapd.socket
Mohannd
  • 151
  • 6