sudo start login shell (-i) and stay at current working directory
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
When I login to root via
sudo -i
sudo changes the working directory of new shell to root's home directory. I can use following commands to keep working directory of parent shell:
sudo -s
sudo su
...
but none of these invoke login shell, which means that files like /etc/profile.d/foobar.sh
are NOT sourced.
How can you you invoke login shell via sudo and stay at the same directory?
EDIT
I can use
sudo zsh -l
The downside is that I'm hard-coding the shell, but that's no big deal, since it probably won't change in my lifetime. :-)
shell sudo login pwd
add a comment |Â
up vote
0
down vote
favorite
When I login to root via
sudo -i
sudo changes the working directory of new shell to root's home directory. I can use following commands to keep working directory of parent shell:
sudo -s
sudo su
...
but none of these invoke login shell, which means that files like /etc/profile.d/foobar.sh
are NOT sourced.
How can you you invoke login shell via sudo and stay at the same directory?
EDIT
I can use
sudo zsh -l
The downside is that I'm hard-coding the shell, but that's no big deal, since it probably won't change in my lifetime. :-)
shell sudo login pwd
Have you triedsu--preserve-environment
? Edit: on mobile, can't test it. I reckon that you could just runsudo (shell) `pwd`" where
(shell)` is your shell
â Stan Strum
May 17 at 18:29
@StanStrum I want to use sudo, because I don't want to type root's password.
â Mark Howard
May 17 at 18:31
@MarkHoward And the 2nd suggestion?
â Stan Strum
May 17 at 18:31
@StanStrum that's what's in my EDIT. If you append-l
it works.
â Mark Howard
May 17 at 18:32
You could usegetent
to look up root's shell, but that might be overkill.
â Ulrich Schwarz
May 17 at 20:09
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When I login to root via
sudo -i
sudo changes the working directory of new shell to root's home directory. I can use following commands to keep working directory of parent shell:
sudo -s
sudo su
...
but none of these invoke login shell, which means that files like /etc/profile.d/foobar.sh
are NOT sourced.
How can you you invoke login shell via sudo and stay at the same directory?
EDIT
I can use
sudo zsh -l
The downside is that I'm hard-coding the shell, but that's no big deal, since it probably won't change in my lifetime. :-)
shell sudo login pwd
When I login to root via
sudo -i
sudo changes the working directory of new shell to root's home directory. I can use following commands to keep working directory of parent shell:
sudo -s
sudo su
...
but none of these invoke login shell, which means that files like /etc/profile.d/foobar.sh
are NOT sourced.
How can you you invoke login shell via sudo and stay at the same directory?
EDIT
I can use
sudo zsh -l
The downside is that I'm hard-coding the shell, but that's no big deal, since it probably won't change in my lifetime. :-)
shell sudo login pwd
asked May 17 at 18:23
Mark Howard
113
113
Have you triedsu--preserve-environment
? Edit: on mobile, can't test it. I reckon that you could just runsudo (shell) `pwd`" where
(shell)` is your shell
â Stan Strum
May 17 at 18:29
@StanStrum I want to use sudo, because I don't want to type root's password.
â Mark Howard
May 17 at 18:31
@MarkHoward And the 2nd suggestion?
â Stan Strum
May 17 at 18:31
@StanStrum that's what's in my EDIT. If you append-l
it works.
â Mark Howard
May 17 at 18:32
You could usegetent
to look up root's shell, but that might be overkill.
â Ulrich Schwarz
May 17 at 20:09
add a comment |Â
Have you triedsu--preserve-environment
? Edit: on mobile, can't test it. I reckon that you could just runsudo (shell) `pwd`" where
(shell)` is your shell
â Stan Strum
May 17 at 18:29
@StanStrum I want to use sudo, because I don't want to type root's password.
â Mark Howard
May 17 at 18:31
@MarkHoward And the 2nd suggestion?
â Stan Strum
May 17 at 18:31
@StanStrum that's what's in my EDIT. If you append-l
it works.
â Mark Howard
May 17 at 18:32
You could usegetent
to look up root's shell, but that might be overkill.
â Ulrich Schwarz
May 17 at 20:09
Have you tried
su--preserve-environment
? Edit: on mobile, can't test it. I reckon that you could just run sudo (shell) `pwd`" where
(shell)` is your shellâ Stan Strum
May 17 at 18:29
Have you tried
su--preserve-environment
? Edit: on mobile, can't test it. I reckon that you could just run sudo (shell) `pwd`" where
(shell)` is your shellâ Stan Strum
May 17 at 18:29
@StanStrum I want to use sudo, because I don't want to type root's password.
â Mark Howard
May 17 at 18:31
@StanStrum I want to use sudo, because I don't want to type root's password.
â Mark Howard
May 17 at 18:31
@MarkHoward And the 2nd suggestion?
â Stan Strum
May 17 at 18:31
@MarkHoward And the 2nd suggestion?
â Stan Strum
May 17 at 18:31
@StanStrum that's what's in my EDIT. If you append
-l
it works.â Mark Howard
May 17 at 18:32
@StanStrum that's what's in my EDIT. If you append
-l
it works.â Mark Howard
May 17 at 18:32
You could use
getent
to look up root's shell, but that might be overkill.â Ulrich Schwarz
May 17 at 20:09
You could use
getent
to look up root's shell, but that might be overkill.â Ulrich Schwarz
May 17 at 20:09
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444448%2fsudo-start-login-shell-i-and-stay-at-current-working-directory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Have you tried
su--preserve-environment
? Edit: on mobile, can't test it. I reckon that you could just runsudo (shell) `pwd`" where
(shell)` is your shellâ Stan Strum
May 17 at 18:29
@StanStrum I want to use sudo, because I don't want to type root's password.
â Mark Howard
May 17 at 18:31
@MarkHoward And the 2nd suggestion?
â Stan Strum
May 17 at 18:31
@StanStrum that's what's in my EDIT. If you append
-l
it works.â Mark Howard
May 17 at 18:32
You could use
getent
to look up root's shell, but that might be overkill.â Ulrich Schwarz
May 17 at 20:09