10

I ran some commands without completely understanding them while trying to get screen brightness working and now I'm stuck with a nasty symlink in '/sys/class/backlight/asus_laptop' that I am trying to get rid of.

I have tried

sudo rm /sys/class/backlight/asus_laptop
sudo rm '/sys/class/backlight/asus_laptop'

su root
rm /sys/class/backlight/asus_laptop
sudo rm /sys/class/backlight/asus_laptop

Going right into directory and typing rm asus_laptop, changing ownership and using Thunar to try to remove it.

I get

rm: cannot remove '/sys/class/backlight/asus_laptop': Operation not permitted

Same goes for unlink, rmdir doesn't work, and Thunar fails.

The permissions on it are lrwxrwxrwx

How can I remove it?

  • 1
    It is the permission on the directory, that matters when removing a file. However /sys is special, I don't know if you can add or remove files. – ctrl-alt-delor Dec 2 '18 at 17:13
28

The sysfs file system, typically mounted on /sys, just like the /proc file system, isn’t a typical file system, it’s a so called pseudo file system. It’s actually populated by the kernel and you can’t delete files directly.

So, if the ASUS laptop support isn’t appropriate for you, then you have to ask the kernel to remove it. To do so, remove the corresponding module:

sudo rmmod asus-laptop

That will remove the relevant /sys entry.

  • Small note: Some files can be removed, what triggers certain actions. I am not sure which ones are there in sysfs, but e.g. cgroupfs allows creating/removing cgroups with mkdir and rm. – allo Dec 3 '18 at 9:36
  • 3
    @allo the distinction is subtle, but cgroupfs as its name suggests is a different file system. sysfs, which is mounted on /sys, only supports reads and writes, it doesn’t support deletion. – Stephen Kitt Dec 3 '18 at 9:44
  • 1
    @StephenKitt: If I as a kernel module writer wanted to add something to /sys I could very well provide my own directory node that has delete wired up. Create gives me the shivers though. mknod() is a special call after all. – Joshua Dec 3 '18 at 18:30
  • @Joshua now you’ve got me intrigued — how would you go about that, without mounting a new kernfs (so no kernfs_create_root) or any other fs? – Stephen Kitt Dec 3 '18 at 19:28
  • Modules can add arbitrary nodes to sysfs and procfs with their own vfs handlers. – Joshua Dec 3 '18 at 19:35

Your Answer

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

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