How to Enable Root Login in Kali Linux – LinuxWays
Kali Linux, unlike other Linux operating systems, allows users to enter the system as a default user. This case was not there in older versions of the operating systems, but with the new and most recent releases of Linux systems, the root login feature is disabled to protect the system security. While users can use the su command to login as a root user on terminal and perform terminal related tasks, there are some scenarios where you will require entering the system as a root user. These scenarios include running older security GUI tools or scripts that are specifically for root execution, and more.
In this guide, you will learn:
How to Enable Root Login in Kali Linux
Before enabling the root login in Kali Linux, you must ensure remembering your root password. If you forgot your root password for Kali Linux, you can run the below-given command to set a new root password:
Enter a new root password, type the new password again to successfully update the root password on your Kali Linux system.
Note: Ensure setting a strong root password for your Kali Linux system to make it hard for someone to crack it.
After setting up the root password, it’s now time to enable the root login in Kali Linux. You can enable root login on Kali Linux for:
How to Enable Root Login in Kali Linux for SSH
For enabling the root login in Kali Linux for SSH, follow the steps given below:
Step 1: First, open SSH configuration file on Kali Linux with nano editor through the below-given command:
sudo nano /etc/ssh/sshd_config
Step 2: Inside the SSH configuration file, scroll down and find the line “PermitRootLogin prohibit-password”. Remove the # sign from the line to uncomment it:
Step 3: Now, replace the “prohibit-password” with yes keyword inside the file:
Step 4: After performing the changes within the SSH configuration file, save them using CTRL+X keys simultaneously. Then add Y for approving the changes, and use the Enter button to close the configuration file and exit back to the terminal.
Step 5: After applying the changes within the SSH configuration file, you must restart the SSH service on Kali Linux using the following command:
sudo systemctl restart ssh
Once the SSH service is restarted, you can enter the Kali Linux system from SSH as a root user using the following ssh command. Ensure adding root as a user and IP address of Kali Linux in place of IP_Address in the below-given command:
How to Enable Root Login in Kali Linux for GNOME or KDE Login
If you want to enable root login in Kali Linux for GNOME or KDE Login, follow the below-given steps:
Step 1: It is advised to install the kali-root-login package on your Kali Linux system that will change multiple configuration files and allow us to enter the system as a root user. This package is optional, and you can skip this step if you don’t require it. In some desktop environments like GNOME GDM3 and KDE, you will need that package, so it is better to install it on Kali Linux from the following command:
sudo apt install kali-root-login -y
Step 2: Now, log out of your system using the highlighted button shown in the image:
Step 3: Then use Log Out button to log out of the current user:
Step 4: At the login screen, enter the username as root and password you previously set in at the start of the process. After entering the root credentials, simply use the LogIn button:
After you have completed the above step, you will be able to enter into the Kali Linux system as a root user, and you can confirm it by opening the terminal. There, you will be able to see your username as root:
Note: To login back to a specific user, log out the system and follow the same procedure for login to the system by replacing root with username and add password for the entered username.
Conclusion
Enabling root login in Kali Linux offers advantages as well as disadvantages. However, if you are sure about your system security, you can enable root login on your Kali Linux system by first setting a strong root password. Doing this will protect your system and prevent the hacker from accessing it as a root user. After setting the root password, you can enable root login in Kali Linux for SSH or GUI login using the methods presented in the above-sections of this blog. Both methods require login credentials like username as root followed by the root password later on.
By day, I am an engineer and researcher, building bridges and figuring out how the universe works. But when the clock strikes five, I turn into a wordsmith!
I write about my adventures on my blog, sharing tips and tricks to help others join the tech fun. I have worked on Raspberry Pi, Ubuntu, Debian, and Laptops. Right now, I have accepted the challenge of working on the Kali Linux system, and with my vast expertise in Linux systems, I will help users overcome the challenges through my blogs.