How to add user to system group: Difference between revisions

From Pengwings
Created page with "The usermod command would normally be used to add a user to a group provided by the OS packages. e.g. adding ruby to docker: sudo usermod -aG docker ruby However this works by adding ruby to the list of users in the group, where the groups are defined in /etc/group In the Atomic Desktop based OS such as Fedora Silverblue/Kinoite the system groups are stored in /usr/lib/group and /etc/group acts as an overlay. Trying to do the above usermod command fails because the d..."
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 6: Line 6:
However this works by adding ruby to the list of users in the group, where the groups are defined in /etc/group
However this works by adding ruby to the list of users in the group, where the groups are defined in /etc/group


In the Atomic Desktop based OS such as Fedora Silverblue/Kinoite the system groups are stored in /usr/lib/group and /etc/group acts as an overlay. Trying to do the above usermod command fails because the docker group isn't in /etc/group so it can't be edited to add ruby.
In the Atomic Desktop based OS such as Fedora Silverblue/Kinoite the system groups are stored in /usr/lib/group and /etc/group file essentially provides additions and overrides to the system groups. Trying to do the above usermod command therefore fails, because the docker group isn't in /etc/group, so it can't be edited to add ruby.


To fix:
To fix:
  cat /usr/lib/group
  cat /usr/lib/group
Copy the docker line
Find the line for the system group you want to add a user to, for example the docker group looks like this:
docker:x:954:
Now edit the normal group file:
  sudo vim /etc/group
  sudo vim /etc/group
Add the docker line, add ruby to the group while you're at it:
Add the line you copied, add yourself to the group while you're at it:
  docker:x:954:ruby
  docker:x:954:ruby
Now reboot
Now reboot
  systemctl reboot
  systemctl reboot
Verify you're in the docker group
Verify you're now in the group
  groups ruby
  groups ruby
Should be working :)
You should see that you are!
ruby : ruby wheel docker
 
Docker now works too!

Latest revision as of 11:17, 15 February 2026

The usermod command would normally be used to add a user to a group provided by the OS packages.

e.g. adding ruby to docker:

sudo usermod -aG docker ruby

However this works by adding ruby to the list of users in the group, where the groups are defined in /etc/group

In the Atomic Desktop based OS such as Fedora Silverblue/Kinoite the system groups are stored in /usr/lib/group and /etc/group file essentially provides additions and overrides to the system groups. Trying to do the above usermod command therefore fails, because the docker group isn't in /etc/group, so it can't be edited to add ruby.

To fix:

cat /usr/lib/group

Find the line for the system group you want to add a user to, for example the docker group looks like this:

docker:x:954:

Now edit the normal group file:

sudo vim /etc/group

Add the line you copied, add yourself to the group while you're at it:

docker:x:954:ruby

Now reboot

systemctl reboot

Verify you're now in the group

groups ruby

You should see that you are!

ruby : ruby wheel docker

Docker now works too!