15

When I run this command it fails:

sudo echo '/usr/local/lib' >> /etc/ld.so.conf 
bash: /etc/ld.so.conf: Permission denied

I don't have any problem running sudo for other tasks. I am using Ubuntu 12.04. It works when connected as root.

Any help will be much appreciated

1
  • 5
    You do a sudo echo but the remainder of that command is NOT executed as sudo (the rerouting is not done as sudo ;-) )
    – Rinzwind
    Apr 10, 2013 at 10:18

1 Answer 1

22

From memory this should do it:

sudo sh -c "echo '/usr/local/lib' >> /etc/ld.so.conf"
2
  • 2
    Could you add an explanation on why this works?
    – Bar
    Apr 1, 2016 at 12:06
  • 1
    @Bar I think it works because sudo only applies to one command at a time. The quotes group two commands (an echo followed by an >>) into one. An alternate approach is to open an editor with sudo and do the edits manually, i.e. sudo gedit /usr/local/lib.
    – apostl3pol
    Oct 2, 2016 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .