In this article, we’ll cover how to log in as root in Ubuntu GUI to access root privileges. Continue reading to find out how to login as a root user in Ubuntu.
Root User in Ubuntu GUI
In Ubuntu GUI, root user privileges are not enabled by default—which means you cannot access GUI as a root user—this is a default security feature to save the Ubuntu desktop environment from unprivileged users. However, you can log in to the Ubuntu machine as root to test the system or access it in critical scenarios.
Since all root privileges are accessible by the sudo command, it is recommended not to use the root account to log in, as it increases the chance of messing up the system. In addition, logging in as a root user is common on servers. However, using the root account in the Ubuntu GNOME desktop interface is uncommon.
How to log in as Root in Ubuntu GUI
In this section, we’ll discuss how you can log in as root in GUI. Follow this tutorial to access Ubuntu as a root user. Also, note that this guide is for educational purposes only since using the root account on GUI is not recommended.
Set the Root Account Password in Ubuntu
The first step to log in as root in Ubuntu is using the root credentials to edit the custom.conf
file. For this step, first set the password as shown below:
sudo passwd root
The output should look something like this:
Type the password for the root account and hit the “Enter” key. However, you can skip this step if the root already has a password.
Activate the Root Account
The second step to log in as root in Ubuntu is to activate the root user account. For this step, use the usermod
command. Specifically, type:
sudo usermod -U root
After that, enable the lightdm
, gdm
, or kdm
mode for the root account.
Edit the Custom.conf File in Ubuntu
Once the account is active, we’ll edit the custom.conf
located at /etc/gdm3/
. Since it is a system file, we’ll create the backup first using the cp
command. Specifically, type:
cp /etc/gdm3/custom.conf /etc/gdm3/custom.conf~
After that, open the custom.conf
file using your favorite text editor. For instance, type:
# nano text editor
sudo nano /etc/gdm3/custom.conf
# vim text editor
sudo vim /etc/gdm3/custom.conf
Once the file is open, add the following lines at the end of the file:
AllowRoot=true
The output should look something like this:
Hit “Ctrl + S” to save and “Ctrl + X” to exit the nano editor. To exit the vim editor, press the “Esc” key. After that, type colon “:” followed by “x”, like this:
:x
Hit the “Enter” key to exit the vim editor.
KDM Ubuntu
In the KDM Ubuntu mode, edit the /etc/sddm.conf
. However, if the file isn’t available, you can create it using the touch
, nano
, or vim
commands. For instance, type:
# touch command
sudo touch /etc/sddm.conf.d/uid.conf
# nano editor
sudo nano /etc/sddm.conf.d/uid.conf
# vim editor
sudo vim /etc/sddm.conf.d/uid.conf
Next, add or change the following lines in the uid.conf
file:
MinimumUid=0
It will show all users on the system, including root.
Output:
Hit “Ctrl + S” to save and “Ctrl + X” to exit the nano editor. To exit the vim editor, press the “Esc” key. After that, type colon “:” followed by “x”, the same as before:
:x
Hit the “Enter” key to exit the vim editor.
Make sure to reboot the system to implement the changes. For this step, execute the reboot
command as shown below:
sudo reboot
LightDM Ubuntu
In the case of the LightDM Ubuntu manager, you’ll have to edit the file located at /etc/lightdm/lightdm.conf
. Execute the following command to open the file:
# nano editor
sudo nano /etc/lightdm/lightdm.conf
# vim editor
sudo vim /etc/lightdm/lightdm.conf
Next, add the line given below:
add greeter-show-manual-login=true
Same as the previous step before this, hit “Ctrl + S” to save and “Ctrl + X” to exit the nano editor. To exit the vim editor, press the “Esc” key. Afterwards, type colon “:” followed by “x”, like this:
:x
Hit the “Enter” key to exit the vim editor.
Lastly, reboot the system using the reboot
command. For example, type:
sudo reboot
Edit PAM Authentication Daemon Configuration File
After that, we will edit the PAM authentication daemon configuration file. This file is located at /etc/pam.d/gdm-password
. Open this file as well using your favorite text editor. For instance, type:
# nano text editor
sudo nano /etc/pam.d/gdm-password
# vim text editor
sudo vim /etc/pam.d/gdm-password
Comment on the following lines in the file:
auth required pam_succeed_if.so user != root quiet_success
This statement denies access to the Ubuntu GUI. to comment, add the pound “#
” operator as shown below:
# auth required pam_succeed_if.so user != root quiet_success
Save your file and exit the text editor.
Reboot the Ubuntu GUI
Once the changes are done, reboot the system using the reboot
command. For example:
sudo reboot
Once the system has rebooted, you will be able to log in as root in Ubuntu GUI. Enter the root username and the root password which you configured before.
Disable Root Login in Ubuntu GUI
To revert the root account access, you can disable the root log in in Ubuntu GUI. for this step, use the passwd
command. Specifically, type:
sudo passwd -dl root
This will revert the changes that you’ve made to enable the root login on Ubuntu GUI.
And that’s all for this guide. Here, we looked at how you can enable log in as root in Ubuntu GUI. This should work for the GNOME desktop environment. However, it is not recommended to enable the root login as you can achieve all root-level tasks with the sudo command. But if you enabled it, make sure to disable it once you’re done.
Learn more about disabling root accounts, modifying kernel variables, and blocking kernel updates at Distroid.
If you liked this article, do share it.