[sf-lug] permissions problem

Alex Kleider akleider at sonic.net
Sat May 27 20:16:01 PDT 2017


I'm working on a little project and have run into a problem I don't 
understand:

$ touch junk                 # setting up
$ chown root:root junk
chown: changing ownership of ‘junk’: Operation not permitted  # 
understood
$ sudo chown root:root junk   # finish set up
[sudo] password for alex:

$ ls -l junk                  # check permissions
-rw-rw-r-- 1 root root 0 May 27 19:56 junk  # result as expected
$ echo "added line" >> junk
-bash: junk: Permission denied  # no surprise here
$ sudo echo "added line" >> junk
-bash: junk: Permission denied  # why didn't sudo allow me to do the 
job?

I don't understand why the last command didn't go through.

Has anyone a suggestion why and (more importantly) how to add a line to 
a privileged file? I suppose I could temporarily change ownership but 
that seems a long way round.
tia

-- 
Alex Kleider
(sent from my current gizmo)



More information about the sf-lug mailing list