When working on the command line, I often change to sudo using
sudo -i. However, my working directory changes automatically to
/root. I never want to go there; I want to stay where I was! How can I achieve this?
You could use
This page from the Ubuntu Forums has a nice summary:
This page from from Ubuntu's documentation has much more background information on sudo.
If you want to use
su - user -c "cd `pwd`; bash"
What’s going on here:
Note that you can replace
I've faced the same issue and I'm not allowed to run anything other than
It goes up a process tree and checks if process owning user changed.