In particular I want to create bridges dynamically, but without the need of running it with sudo. I think it's the group netdev.

But is there, and I'm sure there is, a general answer to the question: How can I determine the group needed to run a program without typing sudo in front of the command

  • This lloks like two questions. Run command without sudo (use /etc/sudoers.d) for group netdev and find which group (top) a command runs under! Which should it be? – George Udosen Dec 13 '18 at 14:44
  • 2
    I'm not sure that's really the right question: in the example you give, AFAIK it's not about permissions required to run the program, it's about the permissions required for the program to modify a device file – steeldriver Dec 13 '18 at 14:47
  • I think he means how do you know which group you should add to user so the user don't have to use sudo. – Alvin Liang Dec 13 '18 at 14:51
  • @AlvinLiang yes that's what I mean. – Kev Inski Dec 13 '18 at 18:11

First run the command (I wish you'd told us which) without sudo. Take note of the device(s) mentioned in the error message.

Use ls -l, followed by the device(s), e.g.

walt@bat:~(0)$ ls -l /dev/ttyS1
crw-rw---- 1 root dialout 4, 65 Dec 13 08:34 /dev/ttyS1

This device allows rw access for the owner (root) and members of the dialout group.

To add yourself to the dialout group,

sudo adduser $USER dialout

To make use of your new dialout group membership, either log out and log in, or newgrp dialout to start a shell with that group membership.

| improve this answer | |
  • I am looking for a general answer. But let's assume I use the command brctl addbr. I prefer using the command usermod to add a user to a existing group. So your solution basically is: ls - l $(which brctl) or something similar to get the group? – Kev Inski Dec 13 '18 at 21:03
  • I don't think there's general answer. If document does not say anything and you don't guess, how do you know which device it will use? – Alvin Liang Dec 14 '18 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.