Ubuntu – How do you modify group membership in Ubuntu Core

ubuntu-coreusers

Running Ubuntu Core 16 on RP3. Attempting to add supplementary group 'test' to my username, but unable to. Created the group using:

sudo groupadd --system --extrausers test

The flags are required for the software I am using (basically trying to get lxd group membership added to my account, but trying to at least do it with a test group first).

Attempting with 'adduser':

alexk1@localhost:~$ sudo adduser --extrausers alexk1 lxd
Adding user `alexk1' to group `lxd' ...
gpasswd: group 'lxd' does not exist in /etc/group
adduser: `/usr/bin/gpasswd -a alexk1 lxd' returned error code 3. Exiting.

Attempting with 'usermod':

alexk1@localhost:~$ sudo usermod -a -G test alexk1
usermod: /etc/group.3813: Read-only file system
usermod: cannot lock /etc/group; try again later.

It's true that the group is not listed in '/etc/group', however 'getent' confirms it's there:

alexk1@localhost:~$ getent group
...
test:x:998:

As listed here, there is a snap command 'create-user' that has the ability to add membership to certain groups upon account creation (the link refers to members of sudo group), so I'm not sure if there is a snap command for modifying group membership (I can't use 'create-user' as I have only one Ubuntu Core install and one Ubuntu SSO account). Ubuntu Core documentation is shockingly bleak and I only discovered the 'create-user' command through bug reports and not any actual documentation.

Best Answer

Ubuntu core manages group membership in /var/lib/extrausers

I edited the groups file and added my username to the group like this:

test:x:998:alexk1

I'm assuming the flag '--extrausers' in the "sudo groupadd --system --extrausers test" command allowed me to do this.