2

Opening vim as sudo -i or sudo - still doesn't let me write to the file.

Trying to change the keyboard backlight settings on my laptop gives me this output; even with sudo I can't change anything in it. Even opening the file with sudo I can't change it and save it.

10:00:35  @ ・ー ・ 
cat sys/class/leds/samsung\:\:kbd_backlight/brightness 
4
10:01:28  @ ・ー ・ 
sudo echo '0' > sys/class/leds/samsung\:\:kbd_backlight/
brightness      device/         max_brightness  power/          subsystem/      trigger         uevent          
10:01:28  @ ・ー ・ 
sudo echo '0' > sys/class/leds/samsung\:\:kbd_backlight/brightness 
-bash: sys/class/leds/samsung::kbd_backlight/brightness: Permission denied
10:01:58  @ ・ー ・ 

Here are the permissions

10:04:15  @ ・ー ・ 
ll /sys/class/leds/samsung\:\:kbd_backlight/
total 0
drwxr-xr-x 3 root root    0 Oct 22 08:44 ./
drwxr-xr-x 3 root root    0 Oct 22 08:44 ../
-rw-r--r-- 1 root root 4096 Oct 22 08:44 brightness
lrwxrwxrwx 1 root root    0 Oct 22 09:26 device -> ../../../samsung/
-r--r--r-- 1 root root 4096 Oct 22 08:44 max_brightness
drwxr-xr-x 2 root root    0 Oct 22 09:26 power/
lrwxrwxrwx 1 root root    0 Oct 22 09:26 subsystem -> ../../../../../class/leds/
-rw-r--r-- 1 root root 4096 Oct 22 09:26 trigger
-rw-r--r-- 1 root root 4096 Oct 22 08:44 uevent

As you can guess, it's really annoying and it's also killing my battery.

Fetts Vett
  • 157
  • 1
  • 10

2 Answers2

0

Try

sudo su -

this will change you to root, and try it this way. Sometimes I observed that this way I have more rights than simply with sudo

muru
  • 197,895
  • 55
  • 485
  • 740
sboda
  • 512
0

You can't write like that through a file descriptor using sudo, the echo runs as root, the output it generates does not. You must use sudo tee to elevate the access, example:

echo 1 | sudo tee [path to sysfs]

You can even append with tee using the -a switch. I do this all the time with ftrace.

echo 'nvme_submit_request'  | sudo tee ${TRACE}/set_ftrace_filter
echo 'nvme_isr'             | sudo tee -a ${TRACE}/set_ftrace_filter
echo 'nvme_process_sglist'  | sudo tee -a ${TRACE}/set_ftrace_filter
ppetraki
  • 5,483