×

消息

EU e-Privacy Directive

This website uses cookies to manage authentication, navigation, and other functions. By using our website, you agree that we can place these types of cookies on your device.

View e-Privacy Directive Documents

You have declined cookies. This decision can be reversed.

I wrote a utility script to do some automatic moving and copying stuff, put it in a directory, exported the dir in $PATH with bashrc and it worked well with my normal user. But when I tried to sudo the script, it couldn't be found. Copy bashrc for root didn't work better. Finally google helped me out: it's the secure_path stuff on my way.

In fact, when we sudo a command, the system makes a env_reset first. So all our settings in bashrc are lost, including customized $PATH. So the solution is to modify /etc/sudoers, either we completely disable the secure_path reset:

 

Defaults !secure_path

the line is to be added right after the first:

Defaults env_reset

or we add our useful path to secure_path, like what we do with $PATH in bashrc:

Defaults secure_path="/the/useful/path"

提交评论


安全码
刷新