Question: Why doesn't -H work?
Paul M. Lambert
plambert at plambert.net
Wed Oct 15 22:46:29 EDT 2003
Your asking your own shell to enter the value of $HOME. So it does.
And it's your home directory, not db2as's. Because it's your shell
doing the substitution.
I'll spell it out:
% sudo -H -u db2as echo $HOME
Your shell does subsitutions:
sudo -H -u db2as echo /home/you
Your shell splits this on words:
'sudo', '-H', '-u', 'db2as', 'echo', '/home/you'
Your shell execs sudo with all but the first word as arguments.
Sudo parses the -H and -u db2as options, becomes db2as, sets the HOME
environment variable, and then runs:
There you go. You got exactly what you asked for!
% sudo -H -u db2as env | grep HOME=
% sudo -H -u db2as sh -c 'echo $HOME'
Hope that helps!
On Sep 29, 2003, at 1:12 PM, Malton, Craig wrote:
> I'm trying to run some commands as so
> sudo -H -u db2as echo $HOME
> I'm running this as user cmalton and $HOME keeps returning as
> /home/cmalton not /export/home/db2as. Does anyone know why -H isn't
> working for me?
> Craig Malton
> IBM Senior Middleware Specialist - HP Project
> sudo-users mailing list <sudo-users at sudo.ws>
> For list information, options, or to unsubscribe, visit:
More information about the sudo-users