Can't echo to file even as root.

Issues related to hardware problems
Post Reply
malapradej
Posts: 4
Joined: 2018/06/18 10:43:36

Can't echo to file even as root.

Post by malapradej » 2018/06/20 08:36:41

I am trying to echo the following to a file as root.

Code: Select all

# echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized
with error

Code: Select all

bash: echo: write error: Invalid argument
using

Code: Select all

ls -l /sys/bus/thunderbolt/devices/0-1/authorized 
permissions are set as:

Code: Select all

-rw-rw-r--. 1 root root 4096 Jun 20 09:21 /sys/bus/thunderbolt/devices/0-1/authorized

lightman47
Posts: 726
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Can't echo to file even as root.

Post by lightman47 » 2018/06/22 18:30:06

I was about to suggest {on the other forum before it disappeared} that perhaps the file was marked 'immutable'.?.? Generally, you don't want to screw with those, but I once had to myself.

The command 'chattr' may be of help.
"The more I learn, the behinder I get"

JohnK2020
Posts: 19
Joined: 2018/06/27 12:08:17

Re: Can't echo to file even as root.

Post by JohnK2020 » 2018/06/28 15:46:51

As far as I know, echo into file is:

Code: Select all

echo '1' >> /home/dudu/file

lightman47
Posts: 726
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Can't echo to file even as root.

Post by lightman47 » 2018/06/28 16:42:29

I was suggesting chattr to check on the file/directory attributes (to see if was marked immutable), thus preventing your attempts to write to it
"The more I learn, the behinder I get"

User avatar
TrevorH
Forum Moderator
Posts: 23675
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Can't echo to file even as root.

Post by TrevorH » 2018/06/28 16:49:22

Anything under /sys is part of the kernel and isn't a real file. If you can't echo into it, it's because the kernel doesn't let you.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

lightman47
Posts: 726
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Can't echo to file even as root.

Post by lightman47 » 2018/06/28 16:56:54

{smacking my head on wall}

I _knew_ that a while back but forgot it was one of those 'dynamic' directories!! Grr. Thanks.
"The more I learn, the behinder I get"

Post Reply