Snap without sudo

As of 17.10, you can use snap without sudo and a polkit password window will come up for you to use.

I just learned you can also run snap login and enter your Ubuntu/launchpad credentials. Then you can run snap commands without a password at all! (Obviously only for secure [enough] situations.)

HI elcste,

could you post an example of the command please. :smiley:

That’s neat. Probably has a wrapper that calls pkexec /path/to/snap

elcste I have two questions:

  1. When you “snap login” do you snap in or snap on? :grin:
  2. Does it have a lease time or you stay logged in forever?

So you can run snap with sudo, just like you need to use sudo to run sudo apt install. For example, to install the ripgrep snap:

sudo snap install rg

You can now leave off the sudo and a password window will appear (and I think this is in 16.04 and maybe 14.04 too, since part of the point of Snaps is that they work the same across versions):

snap install rg
# password window will pop up

What you can also do is log in first, and then you don’t need a password:

snap login
# when prompted, enter Ubuntu account email and password
snap install rg
# this works now without sudo or password window appearing
1 Like

The snap man page has some more details, but not anything about a timeout:



   Authenticates on snapd and the store

   The login command authenticates on snapd and the snap store  and  saves
   credentials into the ~/.snap/auth.json file. Further communication with
   snapd will then be made using those credentials.

   Login only works for local users in the sudo, admin or wheel groups.

   An account can be setup at


Thanks!. :smiley: :smiley:

1 Like