- Root kali linux terminal
- Enabling the root account
- Enabling root for SSH
- Enabling root for GNOME and KDE login
- How to run terminal as root in Kali Linux? How to run a GUI program as root
- What needs to be done to make the terminal run as root?
- 1. Switch to root user
- 2. Open a root session
- 3. Using sudo, including with internal Bash commands
- 4. Using sudo without a password
- How to run a GUI program as root
- Related articles:
- How to Get the root access on Kali Linux 2022.3
- How To Get root Access
- Check Login User Account
- Login as root on Terminal
- Check Login User Account
- Set the Kali Linux root Password
- Login as root in Kali Linux
- IMPORTANT THINGS TO REMEMBER
- Finally
- About The Author
- admin
Root kali linux terminal
There are some cases where you may need to use superuser, root, for an extended period of time. In these cases we can easily access the root account with a simple sudo su (which will ask for the current user’s password), selecting the root terminal icon in the Kali menu, or alternatively using su — (which will ask for the root user’s password) if you have set a password for the root account that you know of. When finished, exit or CTRL+D will take us out of this elevated shell.
However, there may be other times where you may want to use root across multiple sessions without the hassle of elevating privileges. In these situations we will need to install a package and make a few modifications to fully enable the root account for use due to security reasons of keeping the root account disabled by default.
Enabling the root account
The first thing to do is set a root password, which should be different to the current user’s password (in this case kali ). We can do this by doing the following:
[email protected]:~$ sudo passwd [sudo] password for kali: New password: Retype new password: passwd: password updated successfully [email protected]:~$
Please note that the password prompt will not display output as you are typing in the password, but it will still register the keystrokes.
The next thing we need to decide is if we are wanting to use root via SSH or through the login prompt on whichever desktop environment is installed.
Enabling root for SSH
If we look at /etc/ssh/sshd_config we will see a PermitRootLogin line. We will want to change this line to match our use case:
[email protected]:~$ grep PermitRootLogin /etc/ssh/sshd_config #PermitRootLogin prohibit-password # the setting of "PermitRootLogin without-password". [email protected]:~$ [email protected]:~$ man sshd_config | grep -C 1 prohibit-password PermitRootLogin Specifies whether root can log in using ssh(1). The argument must be yes, prohibit-password, forced-commands-only, or no. The default is prohibit-password. If this option is set to prohibit-password (or its deprecated alias, without-password), password and keyboard-interactive authentication are disabled for root. [email protected]:~$ [email protected]:~$ sudo systemctl restart ssh [email protected]:~$
If we have set up SSH key based login for the root account, then we can simply uncomment the appropriate line and continue on. Otherwise, we should change PermitRootLogin to be yes which will allow us to input a password.
Enabling root for GNOME and KDE login
We will first install kali-root-login to change multiple configuration files that will permit us to login to the root account through the GNOME GDM3 and the KDE login prompt. This step is not necessary when using other desktop environments:
[email protected]:~$ sudo apt -y install kali-root-login Reading package lists. Done Building dependency tree Reading state information. Done The following NEW packages will be installed: kali-root-login 0 upgraded, 1 newly installed, 0 to remove and 1516 not upgraded. Need to get 6,776 B of archives. After this operation, 33.8 kB of additional disk space will be used. Get:1 http://kali.download/kali kali-rolling/main amd64 kali-root-login all 2019.4.0 [6,776 B] Fetched 6,776 B in 1s (10.9 kB/s) Selecting previously unselected package kali-root-login. (Reading database . 333464 files and directories currently installed.) Preparing to unpack . /kali-root-login_2019.4.0_all.deb . Adding 'diversion of /etc/gdm3/daemon.conf to /etc/gdm3/daemon.conf.original by kali-root-login' Adding 'diversion of /etc/pam.d/gdm-password to /etc/pam.d/gdm-password.original by kali-root-login' Adding 'diversion of /etc/pam.d/gdm-autologin to /etc/pam.d/gdm-autologin.original by kali-root-login' Adding 'diversion of /etc/pam.d/lightdm-autologin to /etc/pam.d/lightdm-autologin.original by kali-root-login' Adding 'diversion of /etc/pam.d/sddm to /etc/pam.d/sddm.original by kali-root-login' Adding 'diversion of /etc/sddm.conf to /etc/sddm.conf.original by kali-root-login' Unpacking kali-root-login (2019.4.0) . Setting up kali-root-login (2019.4.0) . Installing /usr/share/kali-root-login/daemon.conf as /etc/gdm3/daemon.conf Installing /usr/share/kali-root-login/gdm-password as /etc/pam.d/gdm-password Installing /usr/share/kali-root-login/gdm-autologin as /etc/pam.d/gdm-autologin Installing /usr/share/kali-root-login/lightdm-autologin as /etc/pam.d/lightdm-autologin Installing /usr/share/kali-root-login/sddm as /etc/pam.d/sddm Installing /usr/share/kali-root-login/sddm.conf as /etc/sddm.conf [email protected]:~$
We can now log out of our non-root user account and login to root using the password that we set earlier.
Updated on: 2023-Mar-06
Author: gamb1t
How to run terminal as root in Kali Linux? How to run a GUI program as root
What needs to be done to make the terminal run as root?
Let’s consider several options
1. Switch to root user
In recent versions of Kali Linux, the default user has changed: before it was root, and now it is a regular user.
If you want to revert to the previous option, that is, make the root user the main user, then this is possible.
First, set the root password:
Now, when you turn on your computer, you can log in as root:
As a result, all opened terminals will have elevated privileges.
2. Open a root session
Start a terminal with as a normal user and run in it:
A root user session will be opened, all commands will be executed with elevated privileges.
Another option to start a session with elevated privileges is to run the following command:
To end the root session press Ctrl+d.
3. Using sudo, including with internal Bash commands
In fact, few commands require superuser rights. And for those that require root privileges, just run them with sudo:
But what if we need to add a line to a file requiring elevated privileges with the following command:
sudo echo "something" >> /etc/file_requiring_elevated_privileges
The command must be executed with elevated privileges, which should give write permissions to the file. But in this case, neither > nor >> can be used, including as root. And an error like this will be displayed:
bash: /etc/file: Access Denied
You can work around this problem by opening a superuser session:
Or with the tee command. Use it with the —append or -a options — this is important, without these options the file will be completely overwritten. Example:
echo 'new line' | sudo tee --append /etc/apt/sources.list
The above command will append a new line to the existing file.
But the peculiarity of the tee command is that it will not only add the file, but also print the added line to the console. If you do not want the data to be returned to the console again, then redirect the output to /dev/null.
echo 'new line' | sudo tee --append /etc/apt/sources.list > /dev/null
This will work in a similar way, but no ‘new line’ will be displayed.
Another use case for echo to write or add to a file as administrator:
sudo sh -c "echo 'something' >> /etc/privilegedfile"
The command uses both single and double quotes, which means that if the string you add to the file also contains quotes, then they must be escaped with backslashes.
4. Using sudo without a password
If it is not a problem for you to add sudo before commands, but you do not like entering a password every time, then the following command will allow you to run commands with sudo and will not be prompted for a password:
echo '%sudo ALL=(ALL) NOPASSWD: ALL' | sudo tee --append /etc/sudoers
Use this only if you understand the security risks!
How to run a GUI program as root
Any program, including those with a graphical interface, can be run as root. This is usually required for file managers and text editors, so that it is convenient to navigate through folders and edit files with limited access.
In fact, everything starts in the same way as with the console utilities:
But you need to know the name of the command. You can find out the name of the command using the following algorithm:
For example, a popular text editor with root privileges can be started like this:
On Kali Linux (Xfce), the file manager executable is called thunar. You can run it as root like this:
You can also specify the folder you want to open:
In Cinnamon, the file manager is called Nemo, run as root:
You can also specify the folder to open:
Related articles:
How to Get the root access on Kali Linux 2022.3
- June 1, 2022
- admin
- Kali Linux / Linux Tips and Tricks
In this article, we are going to learn how to get root access and login as a root in Kali Linux. In the older version of Kali by default user is root. But now we have to make a standard user while we install the Kali Linux. After login, we have to use the sudo command to install any application or packages in Kali. So how to get the root access on Kali Linux we have to follow the following steps:
How To Get root Access
The first time we have to login as a normal user’s account which is created while we install the Kali.
Check Login User Account
Now, first of all, you have to open the terminal and you can check the current login user with the help of this command.
Login as root on Terminal
Now we switch the normal user account to the root account so you have to type the following command in the terminal.
Check Login User Account
Now you can check you are in the root you can identify with the symbol of # as well as you can type the same command which is whoami.
Set the Kali Linux root Password
Now you have verified the current login user in the terminal which is root so you have to type passwd command and hit enter, it is asking for a password so you have to enter the password and then verify the password, and that it, you have set the root password using the terminal.
[email protected]:~# passwd New password: Retype new password: passwd: password updated successfully [email protected]:~#
Login as root in Kali Linux
Now you can exit from the root user and close the terminal and logout from the normal user account and login with the root user with the help of a new password.
That’s it this is the way how you can change the root password and login with the root user on Kali Linux.
IMPORTANT THINGS TO REMEMBER
- This article was written only for educational purposes.
- The author can not be held any responsibility for damage caused by the use of these resources.
- You will not use this information to gain unauthorized access or any other legal activity.
If you are using any illegal activities using these techniques kalilinuxtutorial.com can’t hold any responsibility for your action.
Finally
If you have any questions about this article, any feedback, suggestions, or if you want to share your thoughts, please feel free to comment below.
If you want to speak with us directly you can Contact Us.
About The Author
admin
Kali Linux Tutorial blog that publishes articles, Tips, Tricks and Tutorials about Kali Linux operations, new techniques and Linux security.