Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When use sudo -i I will simulate login as root, and current working directory will be jumped to /root.

Is it possible not to jump and keep the working directory unchanged?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

Do you need to simulate an initial log in, you can use sudo -s to just get a root shell.

share|improve this answer
    
Thanks..seems the man page of sudo suck.. e.g. -s [command] The -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in passwd(5). If a command is specified, it is passed to the shell for execution. Otherwise, an interactive shell is executed. –  Howard Mar 7 '12 at 17:35
sudo -i "cd `/bin/pwd` ; /bin/bash"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.