How to Login as Root in Graphical Environment
As a system administrator, it’s often necessary to perform tasks that require elevated privileges. However, logging in directly as the root user is not recommended due to security concerns. Instead, you can create a new user account with root-like privileges and login as them.
In this post, we’ll walk through the steps to achieve this on Linux systems using the pam.d configuration files.
Step 1: Identify the Pam.d Configuration Files
The pam.d configuration files are responsible for managing user authentication. We need to modify two specific files: /etc/pam.d/gdm and /etc/pam.d/gdm-password.
To open these files in a text editor, you can use the following command:
sudo su -c 'gedit /etc/pam.d/gdm'
This will prompt for the root password. Enter it to proceed.
Once the file is open, look for the line that starts with “auth required pam_succeed_if.so user != root quiet”. This line prevents direct login as root.
Step 2: Comment Out the Line
To enable login as root, we need to comment out this line. Select the entire line by pressing Ctrl+A, then press : and type %s root/ #root
, followed by Enter. Replace the word “root” with “#root”. This will comment out the line.
Repeat the same process for the /etc/pam.d/gdm-password file:
sudo su -c 'gedit /etc/pam.d/gdm-password'
And look for the line that starts with “auth required pam_succeed_if.so user != root quiet”. Comment it out in the same way as before.
Step 3: Save Changes and Restart GDM
After commenting out the lines, save the changes to both files. You can do this by pressing Ctrl+X, then Y, and finally Enter.
To apply these changes, you need to restart the graphical display manager (GDM). You can do this using the following command:
sudo systemctl restart gdm
Conclusion:
With these steps, you should now be able to login as root in your graphical environment. Remember that this is not recommended for production environments due to security concerns.
Keep in mind that modifying pam.d configuration files can have unintended consequences if not done carefully. Be sure to test your system thoroughly after making these changes.
By following these steps, you’ve successfully created a new user account with root-like privileges and logged in as them using the graphical interface.