Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to login as root in linux shell?

share|improve this question

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

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

4 Answers 4

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...
share|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. –  Brian Kintz Jul 20 '10 at 11:28

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.

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

use sudo -i command and put your current user password

share|improve this answer

Reboot the computer. In the LILO boot loader, we should press Ctrl + X and type “linux single”. The sh-3.00# prompt should be displayed when Linux starts.

Type “passwd” and type the new password we want to use. Linux will ask us again to type the same password as confirmation.

Reboot the computer and start Linux normally. We should be able to login as root at the login screen. See How to Log In and Work as Root in Linux

share|improve this answer

Your Answer

 
discard

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