LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-02-2020, 08:59 AM   #1
NerdOne
LQ Newbie
 
Registered: May 2018
Posts: 7

Rep: Reputation: Disabled
Question 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
 
Old 04-02-2020, 09:04 AM   #2
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,256

Rep: Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000
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.
 
Old 04-02-2020, 12:47 PM   #3
remmilou
Member
 
Registered: Mar 2010
Location: Amsterdam
Distribution: Debian Sid / XFCE
Posts: 90

Rep: Reputation: 40
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)
 
Old 04-02-2020, 01:08 PM   #4
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,256

Rep: Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000
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.
 
Old 04-02-2020, 01:20 PM   #5
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 885Reputation: 885Reputation: 885Reputation: 885Reputation: 885Reputation: 885Reputation: 885
Quote:
Originally Posted by NerdOne View Post
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.
 
2 members found this post helpful.
Old 04-02-2020, 01:44 PM   #6
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,256

Rep: Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000
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.
 
  


Reply

Tags
chattr, error message, permission denied, permission error, root


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i write to a root:root 750 file with a non-root user? Droa Linux - Newbie 1 05-14-2012 08:49 PM
Root User using Freshclam command cannot write to directory. swamprat Linux - Newbie 2 01-06-2012 09:43 PM
read/write,write/write lock with smbclient fails swatidas11 Linux - Networking 1 03-10-2010 01:27 PM
Slackware 10.0 Samba: root can write, user cannot bhicks Slackware 15 11-19-2004 12:46 AM
Cannot write to SMB share as user, can as root GT_Onizuka Linux - Networking 3 10-03-2004 07:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration