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

  • 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 '13 at 10:18

From memory this should do it:

sudo sh -c "echo '/usr/local/lib' >> /etc/ld.so.conf"
  • 2
    Could you add an explanation on why this works? – Bar Apr 1 '16 at 12:06
  • @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 '16 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.