Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I set PATH in /etc/profile. I do not have any problems in the case of the general user, but PATH does not go when I become the root authority in sudo.

What would you do to override the PATH which is set by /etc/profile even if I become the root authority in sudo?

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

Sudo resets PATH, along with many other environment variables, for security reasons. It doesn't matter what is set in /etc/profile, unless you run sudo -i.

The sudo manual page, under SECURITY NOTES, gives an insight about the security implications, along with the options you have to fiddle in your /etc/sudoers file to modify these restrictions, after you understand the implications of doing so.

share|improve this answer
add comment

root's path is not changed by /etc/profile (security ...)

you have to set it up separately, (e.g. in root's ~/.bash_profile)

share|improve this answer
add comment

update:

If you want to add a specific PATH to the default PATH of your "root" account when using sudo, or sudo -i:

With Ubuntu 10.04.x LTS:

Modify accordingly both the /etc/environment and the etc/login.defs files.

With Ubuntu 12.04.x LTS:

Modify accordingly both the /etc/environment and the /etc/login.defs files as well as the line Defaults secure_path of the /etc/sudoers file (using visudo).

If you're using a GUI and aren't comfortable with the nano editor in text mode, use the following command to edit the /etc/sudoers file with gedit:

sudo EDITOR=gedit visudo

When you'll save the /etc/sudoers file, visudo will check the syntax of your modifications.

If all is OK, you'll go back to the terminal session.

If there is an error, press the letter "e" to edit the /etc/sudoers file again and correct your modification.

I didn't try with Ubuntu 12.10 yet but I guess (and hope) it's the same thing than for Ubuntu 12.04.x!

Cheers.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.