I ran a command to download something with curl

sudo curl roots.cx/get | sh

– and it threw a permission denied error. So I did sudo curl and I got the same error … why is that?

I was able to run the install command without curl, but I needed to sudo, so why does curl not work with sudo?

  • 3
    Can you show the full command ? – Ofiris Feb 13 '13 at 5:28
  • Are you sure the website was not returning the "permission denied" error, rather then Perl ? What variant of Linux are you using and is SELinux running ? – davidgo Feb 13 '13 at 5:44
  • @davidgo I'm using OS X for this... – GiH Feb 13 '13 at 15:44
  • @Ofiris sudo curl roots.cx/get | sh – GiH Feb 13 '13 at 15:45
  • @GiH Try adding a sudo after the pipe – Ofiris Feb 13 '13 at 17:03

Use sudo after the pipe:

curl roots.cx/get | sudo sh

the get script involves some installation, requires sudo to run.

  • Not working on OS X 10.10.3. – Ain Apr 16 '15 at 17:25
  • @Ain in Super User, consider the popular answer to Redirect output to a file permission denied? (2013-05-15). – Graham Perrin Mar 23 '17 at 5:16

Alternatively you can use:

sudo \curl roots.cx/get | sh

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.