Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
The folders might be mounted with noexec. – user298372 Jun 27 '14 at 13:35
Answer from user298372 was the problem for me. Be sure to mount your folder without noexec flag. – Simon Tremblay May 28 '15 at 17:27

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, however this has nothing to do with your question)

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

sudo -i
share|improve this answer

what ever the file it is, you can have the access to it with sudo .

for example In GUI

sudo gedit <path-to-file-name>


sudo nano <path to file name>
share|improve this answer
not true… – maazza Apr 10 '13 at 10:21
also on some systems u get permission denied on /etc/sudoers, instead u use sudo visudo – Moataz Elmasry Nov 15 '13 at 15:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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