In Kali Linux, many commands and tools require root permission to run. However, we can run these commands by prefacing them with the sudo command. But, adding sudo to every command we use and entering the password every time, is quite frustrating.
Also, if there are a number of users, we need to provide them root privileges as most of the commands require root. In the current version of Kali Linux, root login is disabled by default though it also provides an easy option to re-enable root login. Let’s discuss in detail how to add new users and provide root privileges to users on Kali Linux.
Add new user in Kali Linux
We can add users in kali by using the adduser command. The adduser command is similar to useradd command. But, adduser command is more user-friendly than the useradd. It also creates folders, and directories while adding a new user while the useradd command doesn’t.
To add new users, You have to log in as root. Open a terminal window by pressing Ctrl+Alt+T and execute the following command to login as root:
sudo -i
Now, we will add user user1 to a group named user1. It will ask for the password and other information such as Full name, Room number, work phone, home phone, etc which are optional. Execute the following command to add a new user:
adduser --home /home/user1 user1
The above command will add a user user1 with group user1 by creating a directory /home/user1.
Grant root privileges to users
To give root permissions to users, We can do so either by installing the kali-grant-root package or by editing the /etc/passwd file. By granting root privileges, the user will be able to use the sudo command without entering the password.
Add user to the root group
To add users to the root group, We will use the usermod command. Run the following command in a terminal window:
sudo usermod -a -G <group_name> <username>
sudo usermod -a -G root user1
This will grant root privileges to the above user.
Install the kali-grant-root package
First, Update the system repositories by executing the following command:
sudo apt update
Now, install the package kali-grant-root by executing the following command:
sudo apt install kali-grant-root
Configure the above-installed package by running the following command:
sudo dpkg-reconfigure kali-grant-root
You will be provided with a list of options that decides whether to add a user to the kali-trusted group. Select ‘Enable password-less privilege escalation’ from the options to continue. This will add the user to the kali-trusted group.
Now, log out and re-login, and update the repositories. After the update, try any command that requires root permissions. If the above method is successful, You will not be prompted for the password.
Delete a user with root privileges
If you want to delete an existing user with root privileges granted, you can do so by executing the following command:
sudo deluser --remove-home <username>
sudo deluser --remove-home user1
The above command will remove the user user1 along with its directory.
Conclusion
So, We covered adding a new user, granting root privileges using different methods, and deleting a user. When there are several users accessing a system, It is mandatory to manage the root permissions. Using the above methods, You can check on the user’s activity and also any intruding activity. I hope it works for you. Thank you for reading!