What does the -E in sudo -E do?

I'm following the instructions in a tutorial and they say to do sudo -E foo. I cannot find what the -E does through a google search. What does it do and how I could have found that out without asking this question?


Solution 1:

Check the manual: man sudo

-E - The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the -E option is specified and the user does not have permission to preserve the environment.

There's also ExplainShell.com that tries to explain commands with man pages.

Solution 2:

How I could have found that out without asking this question?

Search the Linux manual pages or type man sudo in a Linux shell.


What does it do?

The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the -E option is specified and the user does not have permission to preserve the environment.

Source Sudo Manual