Tone Tone - 1 month ago 6
Linux Question

What does -E mean in sudo apt-get

I have a linux-mint VM that is sitting behind a proxy. I have been trying to install vsftpd using the following command:

sudo apt-get install vsftpd

This gave me the error

Cannot initiate the connection to

So then I remembered somebody had once told me to use the -E flag

sudo -E apt-get install vsftpd

And this worked! Can anyone please explain what this flag means and why it should be used when you are behind a proxy?

Answer Source

-E preserves environment variables. Your proxy connection settings are stored in the env of the current user. If you elevate to root via sudo, those connection settings do not appear anymore to apt-get. With the option, the env variable is kept the same for both your user and root, so apt-get can see your proxy settings.

You can compare what is defined using the following commands :

$sudo env
$sudo -E env