
If you’re using Ubuntu Desktop in a VirtualBox environment, you might need to enable and access the root user account for administrative purposes. By default, Ubuntu disables the root user for security reasons, but you can enable it with a few terminal commands.
In this guide, we’ll walk you through how to enable the root user on Ubuntu Desktop step-by-step. We’ll also show how to set a root password, configure SSH access, and enable root login from the GUI.
System Setup Overview
Before we begin, here’s the setup we’re working with:
- OS: Ubuntu Desktop 22.04.5 ISO
- Virtual Environment: Oracle VirtualBox
- Allocated Resources:
- RAM: 16 GB
- Disk Size: 250 GB
- CPU: 2 cores
Once your Ubuntu VM is installed and up and running, follow the steps below to enable root access.
Step 1: Open Terminal and Switch to Root
First, launch the terminal window in your Ubuntu VM. Run the following command to attempt switching to root:
$ su
![]()
You’ll be prompted to enter the current user’s password. If everything is correct, you’ll switch to the root shell temporarily.
Note: By default, root login is not enabled, so you may get an error unless you set the password, as we’ll do in the next step.
Step 2: Install OpenSSH Server
To manage your Ubuntu system remotely (or test SSH login for root), install the OpenSSH Server:
# apt-get install openssh-server

This command ensures that the SSH service is running, which will later allow root login via SSH if configured properly.
Step 3: Set Password for Root User
Now, assign a new password to the root user. Use the following command:
# passwd root
You’ll be asked to enter a new password and then confirm it. In this example, the password is set to:
root
Note: For production systems, avoid using weak or obvious passwords like 'root'.
Step 4: Modify GDM Password Configuration
To allow root login from the GUI (Graphical User Interface), modify the GDM (GNOME Display Manager) settings.
Open the following configuration file using nano:
# nano /etc/pam.d/gdm-password

Find the second line that starts with:
auth required pam_succeed_if.so user != root quiet_success
Comment it out by adding a # at the beginning:
# auth required pam_succeed_if.so user != root quiet_success

To save and exit:
- Press
Ctrl + O(to write changes) - Press
Enter - Then press
Ctrl + X(to exit nano)
Step 5: Edit GDM3 Custom Configuration
Next, edit the custom GDM3 configuration to allow root GUI login:
# nano /etc/gdm3/custom.conf

Add the following line above the [Security] section:
AllowRoot=true

Again, use Ctrl + O, Enter, and Ctrl + X to save and exit the file.
Step 6: Enable SSH Root Login
To allow root login via SSH (optional but useful), you need to edit the SSH configuration file:
# nano /etc/ssh/sshd_config

Find the line that starts with:
#PermitRootLogin prohibit-password
Uncomment and modify it to:
PermitRootLogin yes

Save and exit as before (Ctrl + O, Enter, Ctrl + X).
Now, restart the SSH service for the changes to take effect:
# service ssh restart
Step 7: Login as Root from GUI
To test if root login is working from the GUI:
- Lock your Ubuntu screen or restart the machine.
- On the login screen, slide up (from top to bottom).
- Click on “Not listed?” below the user list.

- Enter
rootas the username, and press Enter.

- Enter the root password (we used ‘root’ earlier), and press Enter.

You should now be logged into the root account in the Ubuntu desktop environment.
To confirm in terminal:
$ whoami
Or simply open a terminal, and you should see:
root@your-hostname:~#

That’s it! You’ve successfully enabled the root user on Ubuntu Desktop 22.04.5 in a VirtualBox VM. Now you can log in as root both via GUI and SSH (if needed), perform administrative tasks, and manage your Ubuntu system more flexibly.
Summary of Commands
su
apt-get install openssh-server
passwd root
nano /etc/pam.d/gdm-password
nano /etc/gdm3/custom.conf
nano /etc/ssh/sshd_config
service ssh restart
While enabling the root user gives you full control over your system, it also opens potential security risks. For long-term use, consider disabling root login again or using sudo for admin tasks.

1 Comment
Comments are closed.