LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   root user cannot write on file (https://www.linuxquestions.org/questions/linux-newbie-8/root-user-cannot-write-on-file-4175672408/)

NerdOne 04-02-2020 07:59 AM

root user cannot write on file
 
Hi,

I was trying to edit the following file as root:

/sys/module/pcie_aspm/parameters/policy

As in the title I cannot write on this file even though I am logged as root.

Permissions on this file are set rwx for owner, group, and others (chmod 777)

I tried to overwrite the file by using 'echo "string" >/sys/module/pcie_aspm/parameters/policy' and through vi/vim/nano

I also trying to set chattr attribute by typing:
chattr -a /sys/module/pcie_aspm/parameters/policy
chattr -i /sys/module/pcie_aspm/parameters/policy

both returning: "inappropriate ioctl for device"

Do you know how I can write the file?

Thanks for you time

sevendogsbsd 04-02-2020 08:04 AM

First, changing permissions of a file, especially a system file to 777 is a terrible practice and not a solution at all. A quick google revealed this: https://serverfault.com/questions/81...off-at-runtime.

remmilou 04-02-2020 11:47 AM

Is /sys mounted rw?
Type (as root) mount| grep sysfs to check
Should give something like: sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)

sevendogsbsd 04-02-2020 12:08 PM

Regardless of how. /sys is mounted, changing perms to 777 on any file is a monumentally stupid idea, especially a system file. That was my point to the OP.

ehartman 04-02-2020 12:20 PM

Quote:

Originally Posted by NerdOne (Post 6107002)
I was trying to edit the following file as root:

/sys/module/pcie_aspm/parameters/policy

As in the title I cannot write on this file even though I am logged as root.

Actually all the "files" in /sys aren't real files, they're a reflection on the state of the kernel and its modules. Some of these are changable, others are not but must be changed by (supported) parameters on the specific modprobe for it at bootup. I quote (for the "scaling governor" setting of the cpu:
Quote:

# Attempt to apply the CPU scaling governor setting. This may or may not
# actually override the default value depending on if the choice is supported
# by the architecture, processor, or underlying CPUFreq driver. For example,
# processors that use the Intel P-state driver will only be able to set
# performance or powersave here.
So you will have to read the documentation of the pcie_aspm module to find out which parameters are changable (and how). I haven't got one myself, so cannot help you further.

sevendogsbsd 04-02-2020 12:44 PM

The link I posted for OP appears to show how to do. this. Thank you ehartman for the file explanation - I had thought these files were in the situation you described but wasn't sure.


All times are GMT -5. The time now is 05:27 AM.