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?
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?
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.
pipas root: Is `sudo pip install` still a broken practice?, How to set up and use a virtual python environment in Ubuntu? See also pipenv. More broadly related, onsudoand-H: Why should users never use normal sudo to start graphical applications?, What specific bad things happen when gedit is used with sudo?, How does sudo handle $HOME differently since 19.10? – Eliah Kagan Jan 27 '20 at 19:24