How to login as root in linux shell?

link|improve this question
feedback

migrated from stackoverflow.com Jul 20 '10 at 10:39

This question came from our site for professional and enthusiast programmers.

3 Answers

The correct way to login as root is to type:

su -

This works on systems where sudo is inavailable or not configured.

Some distributions disallow logging in as root and then one should run his commands like this:

sudo MyCommandHere...
link|improve this answer
1  
If you need to run a lot of commands as root but are forced to use sudo, sudo -s will get you a root shell too. – elmugrat Jul 20 '10 at 11:28
feedback

I'd comment on sagar's answer if I could, as I wish to add that while

sudo -i

will log you in as root in the shell, it will move you to its home directory (/root) as well.

Edit: As said by Andreas,

sudo -s

would instead allow you to remain in your current directory, which may be useful.

link|improve this answer
2  
you could also use sudo -s – Andreas Jul 20 '10 at 10:50
feedback

use sudo -i command and put your current user password

link|improve this answer
feedback

Your Answer

 
or
required, but never shown