This is a discussion on sudo ignores -H within the Linux Security forums, part of the System Security and Security Related category; I can't get sudo to change directories to the home dir of the target user, whether or not I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? Also wanted to try "always_set_home" in /etc/sudoers, but I don't know where to put it (man page doesn't say). SUSE 9.3 |
|
|||
|
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 |
|
|||
|
Jeremiah DeWitt Weiner wrote: > 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. Ah, I understand, thanks! I wanted to be logged in as "frank" and run a command, say "martys_script" as user "marty". The command is stored in $HOME/bin/, where $HOME is marty's. How do I do that? I tried: sudo su - marty martys_script (even with path), but then I get asked for a password (sudo didn't, but su did, I think). Also when I try something like sudo -i -u marty ls I get the reply ls: command not found What am I doing wrong? |