On 16 Aug 20:43, Chris G wrote:
On Mon, Aug 16, 2010 at 06:45:55PM +0100, Tim Green wrote:
On 16 August 2010 17:34, Chris G cl@isbd.net wrote:
I tend to use 'sudo -s' when I want to do a series of things as root, it generally works fine but I have just noticed a minor issue. It doesn't set a proper root environment so that you still have the environment of the user who sudo'ed to root - in particular there is the PATH which may have all sorts of oddities on it and HOME is still set to your home directory.
sudo su -
Aha, brilliant, thanks. It's obvious when you think about it but I'd somehow got hooked on 'sudo -s'.
Except that's the wrong answer. *sigh*.
sudo -i
Which fires off a login shell as the user you're sudoing to, so, for instance, I tend to use: sudo -u <someotheruser> -i
At which point I'm running their login shell, I am them, and I have the environment setup as them. Works, is much cleaner than wrapping a privelege escalation tool in a privilege escalation tool, and gives the correct results.
Simples.