Having a problem understanding sudo and setting environmental variables
Hello,
I'm having difficulty understanding sudo and environmental variables. I'm currently setting up vagrant on a host so I can play with adding and removing linux VMs and try and learn Linux better. Host is CentOS 7. When I run Code:
$ sudo vagrant up Code:
# ll /root/.vagrant.d/boxes Code:
$ df -h / Code:
$df -h /var https://stackoverflow.com/questions/...he-home-folder Code:
export VAGRANT_HOME=/path/to/vagrant Code:
# cp -r ./.vagrant.d/ /var /root/.vagrant.d/boxes and Code:
$ export VAGRANT_HOME=/var/.vagrant.d Code:
$ sudo vagrant up /root/.vagrant.d/boxes So I'm thinking maybe sudo runs a command as root and not just with root permission? I do the same process over again Code:
$su - Code:
$ sudo vagrant up Code:
$ sudo ls -lah /root/.vagrant.d/boxes |
By default, sudo retains only a few select variables from the user environment. To change this, see
1) the sudo option -E / --preserve-env; 2) description of the env_keep setting in sudoers(5). |
Close. sudo runs the designated command as another user entirely for the duration of that command. If no use is designated at runtime then the default is root. You'll want to look more closely at some of the options you pass to sudo, such as --preserve-env or --preserve-env=... where ... is the list of variables to pass over to the new user. You may have to edit /etc/sudoers to list the variables allowed.
Code:
... |
That -E environment option seems to be what I was missing.
Code:
$ printenv | grep VAGRANT |
All times are GMT -5. The time now is 05:01 AM. |