0

I'm using Arch Linux. I have a few directories that I don't want any user access to. So I've kept it locked with access to sudo only.

I have a user "alarm". I don't want "alarm" to access those files, so the user can't run sudo. BUT, I want him be able to switch networks, user netctl.

How do I give him those permissions?

1 Answer 1

0

When you refer to giving user a permission to run sudo you usually think of giving him permissions to run any command on behalf of the user root. Butsudoersfile allows much more detailed configuration options that can give permissions to run only one particular command withroot` permissions.

For example add the following to the sudoers file (using visudo):

alarm ALL=(ALL) NOPASSWD: /usr/bin/netctl start wlan0-ssid

to limit the scope of sudo for user alarm just to one specific command with a specified argument: /usr/bin/netctl start wlan0-ssid. It will not give this user any more permissions and he won't be able to access any files (as it would required running other commands which are not specified).

Add more lines and customise them to fit your configuration.

5
  • But he would get access to my files that are for sudo access only, right? Aug 3, 2016 at 10:42
  • No, user alarm would only be able to run the specified command. There is no such thing as "files for sudo access" anyway.
    – techraf
    Aug 3, 2016 at 10:50
  • Is something like this possible without sudo? Aug 3, 2016 at 11:10
  • That's what sudo was built for. What problem are you trying to solve?
    – techraf
    Aug 3, 2016 at 11:12
  • actually i need to restrict access to some files. the whole system is on RPi. So if someone screws the sudoers file by plugging in SD card to PC, I'm screwed Aug 3, 2016 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .