7

I've had multiple times that I wasn't allowed to edit a file. Even when I chmoded to 777 and opend the file with sudo. E.g. the file /sys/kernel/debug/vgaswitcheroo/switch in this tutorial.

First, how is this possible? Second, how can I get access to this sort of files?

2
  • 2
    The folders might be mounted with noexec.
    – user298372
    Jun 27, 2014 at 13:35
  • Answer from user298372 was the problem for me. Be sure to mount your folder without noexec flag. May 28, 2015 at 17:27

1 Answer 1

6

It is not enough to have read permission on a file in order to read it. You also need to have read permission on the directory it belongs to. In the case of /sys/kernel/debug/vgaswitcheroo/switch the problem is /sys/kernel/debug which, by default, is readable only by root:

$ ls -ld /sys/kernel/debug
drwx------ 22 root root 0 Nov 20 18:25 /sys/kernel/debug

You need to chmod a+r /sys/kernel/debug to have access to the contents of that directory.

(I would not recommend it, since giving global access to /sys/kernel/debug is not a safe thing to do, but this is a different problem.)

The most common way to access such files is to use a root shell:

sudo -i

You must log in to answer this question.

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