I have an unusual problem and I'm not familiar enough with Linux permissions to solve it myself.

I've been given a bash script that creates a new folder inside /sys/kernel/config/usb_gadget, then to create other folders and files inside it. Without being root, this isn't allowed.

I tried using chmod to give my user full access to the usb_gadget folder, but:

  1. This resets when the machine is rebooted.
  2. My user can create a folder inside usb_gadget, but that folder doesn't give me sufficient permissions.


Only my user can create a folder only with name myfolder inside usb_gadget. Within that folder, the user can do whatever they need to do. Even better, certain elements of that folder are also preset and the user cannot do anything with those either.

Or, give my user the ability only to run the bash script, and the bash script the ability to make the changes it needs as sudo.

What's a smart way to go about this that doesn't take an axe to security?

  • /sys is included in ths OS as a virtual filesystem(sysfs) which is a ram-based filesystem. It gets rebuilt at each reboot. Which is why your permissions are changed after each reboot. – Jaken551 Apr 11 '18 at 7:29
  • @Jaken551 In that case, is there a secure way to alter these permissions after /sys is set up? Plus, this doesn't seem to change the fact that even with all permissions, my user can create a subfolder but isn't given permissions to that folder either. – sscirrus Apr 11 '18 at 16:01

Your Answer

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

Browse other questions tagged or ask your own question.