Thread: sudo ignores -H
View Single Post

  #2 (permalink)  
Old 11-08-2005
Jeremiah DeWitt Weiner
 
Posts: n/a
Default Re: sudo ignores -H

frwarner <frankwarner4499@yahoo.com> wrote:
> I can't get sudo to change directories to the home dir of the target
> user, whether or not I pass the -H option on the command line. Any
> ideas?


Because that's not what -H does. It sets the $HOME variable; it
does not change your current directory. I assume you are running a
shell with sudo, which is why you say "I can't get sudo to change
directories". If you want it to change to the target user's home
directory, use 'sudo su - targetuser' or 'sudo -i'. From the man page:

-i The -i (simulate initial login) option runs the shell
specified in the passwd(5) entry of the user that the
command is being run as. The command name argument
given to the shell begins with a - to tell the shell
to run as a login shell. sudo attempts to change to
that user's home directory before running the shell.


--
Oh to have a lodge in some vast wilderness. Where rumors of oppression
and deceit, of unsuccessful and successful wars may never reach me
anymore.
-- William Cowper
Reply With Quote