Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily
05/14/2025 •

Unlock Root Access in Ubuntu

Enabling the default root password in Ubuntu allows direct root login, providing full system control. This guide walks you through securely unlocking root access while maintaining system security. Learn the essential steps to set a root password, enable root login, and follow best practices to safeguard your system.

By default, Ubuntu disables the root account for security reasons and encourages the use of sudo. However, if you want to enable the root account.

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily
Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily

Follow these steps:

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


Step 1: Set a Root Password

The root account exists but is locked by default. You need to set a password for it.

      sudo passwd root
    
  • You will be prompted to enter and confirm a new root password.

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


Step 2: Switch to Root User

Once the password is set, you can log in as root using:

      su -
    
  • Enter the root password you just set.

OR:

      sudo -i
    
  • This gives you a root shell without needing to set a password.

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


Step 3: Allow Root Login via SSH (Optional)

If you want to allow root login over SSH, edit the SSH configuration file:

      sudo nano /etc/ssh/sshd_config
    

Find the line:

      PermitRootLogin prohibit-password
    

Change it to:

      PermitRootLogin yes
    

Save the file (Ctrl + X, then Y and Enter), and restart SSH:

      sudo systemctl restart ssh
    

Check the SSH status:

      sudo systemctl status ssh
    

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


Step 4: Verify Root Access

Check if you can switch to root:

      su -
    
      whoami
    

It should return:

      root
    

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


Step 5: (Optional) Disable Root Login Again for Security

If you no longer need root login, you can disable it by locking the password:

      sudo passwd -l root
    

This prevents direct root login while still allowing sudo access.

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


Best Practices for Security

  • Instead of using root, it’s better to use sudo:
      sudo -s
    
  • If you must use root, ensure SSH root login is disabled unless necessary.
  • Use key-based authentication instead of passwords for SSH.

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


Conclusion

Enabling the default root password in Ubuntu allows direct root login, providing full system control. This guide walks you through securely unlocking root access while maintaining system security. Learn the essential steps to set a root password, enable root login, and follow best practices to safeguard your system.

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily


https://ubuntu.com/tutorials

https://sanchitgurukul.com/tutorials-cat

Unlock Root Access in Ubuntu: Enable Default Root Password Securely & Easily

This article provided insights on the topic. For latest updates and detailed guides, stay connected with Sanchit Gurukul.

Disclaimer: This article may contain information that was accurate at the time of writing but could be outdated now. Please verify details with the latest vendor advisories or contact us at admin@sanchitgurukul.com.

Discover more from

Subscribe now to keep reading and get access to the full archive.

Continue reading