L
L
ldmitriy2019-09-30 21:12:13
linux
ldmitriy, 2019-09-30 21:12:13

Why is the -H flag used in SUDO?

For example, I met the following command sudo -H python3 -m pip install flask
According to the documentation for sudo, I did not understand the use of -H

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2019-09-30
@sergiks

-H
The -H option sets the HOME environment variable to the target user's home directory (root by default) as defined in the passwd(5) file. By default, sudo does not modify HOME (see set_home and always_set_home in sudoers(5))

On some systems this is the default option, on others a switch is required -H or --set-home
Install flask in the root home folder - will not be available to other users.

P
pfg21, 2019-09-30
@pfg21

there are small bookmarks in the system to identify the temporary elevation session.
those. working under sudo as a normal user will be different from working as a full-fledged root (or other user). from under any user, sudo will substitute its parameters.
[email protected]:~$ sudo echo $HOME
/home/pfg
for example so that the sudo prefix does not break the usual ~
[email protected]:~$ ls -l ~/wwww
-rw-rw-r-- 1 pfg pfg Sep 39 28 23:39 /home/pfg/www
[email protected]:~$ sudo ls -l ~/wwww
-rw-rw-r-- 1 pfg pfg Sep 39 28 23:39 /home/pfg/wwww

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question