[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Environment Variables for sudo



Timothy Cowlishaw wrote:

Hi All,

am having a bit of a problem with setting environment variables on my web server. I need to set the following, for all users, including root.

<snip>

this works fine for normal users (and for root when using su, which i had disabled), but apparently not for root (via sudo).

the output from a 'sudo env' is this:

TERM=vt100
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/ usr/X11R6/bin
LOGNAME=root
USER=root
SUDO_COMMAND=/usr/bin/env
SUDO_USER=tim
SUDO_UID=1000
SUDO_GID=1000


could anyone enlighten me on where sudo gets its environment variables from, as it apparently is not in /root, as i expected! any ideas what i might be doing wrong / overlooking?

(First, is that as typo? (spurious space in PATH))

I would assume that sudo merely executes the program, and does not start a new shell (unless you ask it to), thus my assumption is that it's your env, merely executed with root's privilages.

As for su, from the man page:
OPTIONS
      -      make this a login shell
So, if you want to be root, AND have settings associated with root's login, use:
su -
As opposed to just:
su


Hope that helps.



Reply to: