How to gain root privileges in Kali Linux?

The root username or account has default permissions to all available commands and files in Linux or any other Unix-like operating system. It is also known as superuser, root account, and root user. Username: "kali" is the standard credential to log into a new Kali system. This establishes a session for the user "kali", which you must use after "sudo" to gain root privileges. Kali Linux used the root account by default until recently. In the current version of Kali, the root login is restricted, allowing you to use your normal user account to access the GUI. The reason behind this modification should be clear, but if you are a Kali user, you should already be familiar with Linux systems; therefore, allowing you to log in as root is a bit risky. We will create a non-root user with administrative capabilities when installing Kali Linux. Other Linux distributions follow a similar procedure. The default user in older versions of Kali is root. But first, we have to create a normal account before installing Kali Linux. To install any program or package under Kali, we must first log in and then use the sudo command. Therefore, in order to obtain root privileges of Kali Linux, we must follow the method in the appendix.

method 1

If many users share a system, some of them may wish to act as administrators to manage the entire system. In order not to directly affect the operation of the system and facilitate sharing among different users, appropriate users can be granted administrator privileges, and other users can be granted non-root privileges. If there is a root user, it will be very difficult for an attacker to break into the system. Using sudo and disabling the root account can mislead intruders because they won't know which account has administrator privileges. Sudo policies can be created and deployed across corporate networks as well as Kali Linux distributions. Having a root password improves monitoring because it allows you to see what other users are doing in the system and if any intrusions are taking place.

Step 1: First, download the kali-root-login package with the apt package manager.

$ sudo apt install kali-root-login
复制代码

Step 2: Next, use the commands listed below to configure the program we just downloaded.

$ sudo dpkg-reconfigure kali-grant-root
复制代码

Step 3: After executing the above command, the screen shown below will pop up.

Step 4: Before hitting enter, make sure "Enable passwordless privilege escalation" is selected to proceed further.

Step 5: In that section, the user will be added to the "kali-trusted" group, which you can verify from the attached screenshot.

Step 6: It's That Simple. You can even use sudo commands to execute all subsequent commands as root, but you never need a password. Try logging out and back in, and executing a command that normally requires root privileges to see if that works.

$ sudo apt update
复制代码

Method 2

On Kali Linux 2021, we connect as a non-root user by default and we have to set the root password ourselves. We don't even know the root password in the first session, so we can't log in indirectly. Instead, we must log in as a non-user, which was established when we installed Kali Linux.

Step 1: To get started, you must first open a terminal, then use this command to determine the current logged-in user.

$ whoami
复制代码

You can check, in our system the username is kalsoom.

Step 2: To change the standard user account to the root account, execute the command referenced below in Terminal.

$ sudo -i
复制代码

Step 3: Now you can verify that you are in the root directory by using the attached command.

The output shows that the username is "root".

Summarize

In this tutorial, we have learned how to grant root privileges to a normal user in Kali Linux. You can use the instructions in this guide to prefix any command with sudo and never have to enter your password again. When the developers of Kali restricted root logins in the latest release, they must have expected some users to be irritated; thus, they provided many recovery options. One word of caution when using the root password: keep it securely under control; otherwise, the system may be compromised. I hope this article has been instructive for you when working on Kali Linux. You can use either of these two methods to gain root privileges on your system.

Guess you like

Origin blog.csdn.net/2301_77498991/article/details/130505567