3

Is there a way to run sudo -E bash - without the sudo command?

I have the command curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - that I want to run inside an Ubuntu container where no sudo exists. By running it with Docker though I provide the Docker parameter -u root:sudo so that everything inside executes as root.

The command sudo -E bash - fails though, because sudo does not exist. Is there a way to just run -E bash -?

  • 2
    -E is a switch for sudo, not a separate command. – ajgringo619 Nov 11 at 22:40
6

The -E is an option of the sudo command, not a part of the actual command you are running with elevated privileges.

From man sudo:

 -E, --preserve-env
             Indicates to the security policy that the user wishes to pre‐
             serve their existing environment variables.  The security
             policy may return an error if the user does not have permis‐
             sion to preserve the environment.

So as you don't use sudo at all, the environment will not be modified anyway. You don't need to replace this option with anything. Just

curl -sL https://deb.nodesource.com/setup_13.x | bash

(Btw. the trailing - argument after bash has no effect, you can omit that too.)

Whether it is advisable regarding security to directly run unverified code fetched from an online source as root is another question though...

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.