Target users environment

Matthew Hannigan mlh at
Fri Sep 6 10:59:36 EDT 2002

Robert Cross wrote:
> Sorry if this is a RTFM question.
> We've got a lot of scripts that run as root that do
>  su - someuser "-c cd somedir; ${somesymbol}/someprogram"
> now these rely on the 'su -' part, i.e. inheriting the default enviroment
> of 'someuser'. Is there
> anyway to use sudo to do this?

Bit of FAQ this one.  The way to do the "su - .." thing is to ...
... do the "su - .." thing!!


     sudo "su - someuser '-c cd somedir; ${somesymbol}/someprogram'"

though it gets a bit hard to expand the ${somesymbol} AND match
that against a valid sudoers config line.

PS. Why do you have the -c in there?

PPS. That's one hell of a disclaimer that Scottish Courage tack
       onto your email.

More information about the sudo-users mailing list