7
1
How to login as root in linux shell?
7
1
How to login as root in linux shell?
8
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...
6
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.
2you could also use sudo -s – Andreas – 2010-07-20T10:50:11.443
How to use this together with the-S
flag in this fashion: echo "mypassword" | sudo -Si
? Its not working and telling me -bash: line 1: mypassword: command not found
. – kiltek – 2019-07-03T09:02:40.823
2
use sudo -i command and put your current user password
0
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
2If 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 – 2010-07-20T11:28:11.350