Forum Thread: How to Get a Root Shell in Terminal as a Non-Root User in Kali Linux (user@kali –> root@kali)

I'd like to change my aneesh@kali to root@kali in terminal prompt.

3 Responses

If you installed Kali 2020.1 or later, you had to create an admin user instead of the default root in previous versions.

If that's the case and you already have a root user with a password, you can do the following to get a root shell, where the password is the password of "root" and not your current user. You'll then have a "root@kali:/home/kali#" prompt and you can "cd" to the root directory.

kali@kali:~$ su
Password:

root@kali:/home/kali# cd
root@kali:~#

You can also use "sudo -s" to get root access in your current shell.

kali@kali:~$ sudo -s
Password:

root@kali:/home/kali# cd
root@kali:~#

To jump right to root's directory, use the following instead for an interactive root shell.

kali@kali:~$ sudo -i
Password:

root@kali:~#

If there is no root user password, try the following to add a password like "toor" — the old root password for Kali Linux versions before version 2020.1. A stronger password is obviously better.

kali@kali:~$ sudo su
[sudo] password for kali:

root@kali:/home/kali# passwd root
New password:
Retype new password:
passwd: password updated successfully
root@kali:/home/kali# exit
exit
kali@kali:~$

Afterward, you can use "su" and the root password to get the root prompt in your current user session.

kali@kali:~$ su
Password:

root@kali:/home/kali# cd
root@kali:~#

To switch to a terminal that has "root@kali:~#" instead of using it in your current user session, hit the power button in the top right of Kali, select "Switch User," and log in with "root" as the user and whatever password you chose. You'll then see the root prompt in a terminal window:

root@kali:~#

You may not want to switch users like that. But you could also use the following.

kali@kali:~$ sudo apt install -y kali-grant-root && sudo dpkg-reconfigure kali-grant-root

That will set you up with passwordless sudo, so you don't have to type in "kali" or whatever your user password is every time you run a sudo command.

You have no idea how nice it is to see someone on these forums who is competent. Fantastic and comprehensive explanation. Cheers, mate.

Share Your Thoughts

  • Hot
  • Active