What does '-H' flag in 'sudo -H' mean?

When I was installing Python 3 on Ubuntu 18.04, I came across the command

sudo -H pip install -U pip

What does -H do?

1

1 Answer

From man sudo:

-H, --set-home Request that the security policy set the HOME environment variable to the home directory specified by the target user's password database entry. Depending on the policy, this may be the default behavior.

So the -H flag makes sudo assume root's home directory as HOME instead of the current user's home directory. Otherwise some files in the user's home directory would become owned by the root, which may lead to various problems.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like