1

Okay, so I'm having a weird issue where I've already done chown -R myuser:myuser folderName and chmod 777 -R folderName

and upon attempting deletion of these files or the folder using rm -f, I get a mysterious and incredibly annoying error message:

root@delphi:/sys/kernel/security/apparmor/policy/profiles# sudo rm -rf usr.bin.freshclam.0
rm: cannot remove 'usr.bin.freshclam.0/sha1': Operation not permitted
rm: cannot remove 'usr.bin.freshclam.0/attach': Operation not permitted
rm: cannot remove 'usr.bin.freshclam.0/mode': Operation not permitted
rm: cannot remove 'usr.bin.freshclam.0/name': Operation not permitted
root@delphi:/sys/kernel/security/apparmor/policy/profiles# 

Even though the folder and all its files are owned by me, the root user, and permissions are set to rwxrwxrwx for the directory and all its included files, I simply cannot delete them. WHY??? Help would be appreciated here, I would like full control of my filesystem.

Anwar
  • 76,649
  • The following attempt produces this error message: sudo chattr -i /sys/kernel/security/apparmor/policy/profiles/usr.bin.freshclam.0/attach chattr: Inappropriate ioctl for device while reading flags on /sys/kernel/security/apparmor/policy/profiles/usr.bin.freshclam.0/attach – Nicholas Stommel Sep 10 '16 at 18:37
  • 3
    What are you trying to achieve here? AFAIK /sys is a dynamically created filesystem representing the kernel-hardware interface - it's not something that you should normally be trying to manipulate "files" on – steeldriver Sep 10 '16 at 18:52

1 Answers1

2

/sys is the mount point for sysfs (a form of tmpfs), which represents Linux kernel's internal data structure especially used for exporting hardware related parameters, it was introduced in the kernel version 2.6.

The kernel only allows you to do certain predefined operations like reading from a file, or writing to a file to change the value of some parameter on runtime but all these operations can be performed because kernel provides interface to do the operation. Deleting would mean to altering kernel's internal data structure, which is prohibited by the kernel, same goes for creating file in /sys (technically, if kernel allows, you can do these too). So deleting (doing unlink(2)) a file from sysfs is not permitted by the kernel (at least i am not aware of one), irrespective of the permission.

heemayl
  • 91,753