Skip to content
Follow
Ubuntu Linux

How to Enable Root User on Ubuntu 24.04

Richard
Written by
Richard
Feb 27, 2025 Updated Sep 15, 2026 3 min read
How to Enable Root User on Ubuntu 24.04
How to Enable Root User on Ubuntu 24.04

The root user on Ubuntu 24.04 is the primary administrator account that gives you complete control over every file and setting on your system. Linux keeps this powerful account locked by default to protect your computer from accidental mistakes.

Advertisement

Unlocking direct root access on Ubuntu 24.04 takes just a few steps in the terminal using the sudo command to create a new password. Once you finish this setup, you can log in directly as the root user whenever you need to manage system files.

⚡ Quick Answer

Set a password for the root account using `sudo passwd root`. Then, switch to the root user with `su -`. This grants full administrative privileges to your Ubuntu system.

Advertisement

Enable root

To enable root user Ubuntu access on version 24.04, you need to open your terminal and set a password for the built-in administrator account. Ubuntu keeps the root account locked by default for security reasons. Running specific commands in the command line unlocks this account so you can log in directly with full system privileges whenever you need to perform advanced administrative tasks.

Switch to the root account with the `sudo -i` command to begin enabling the root user on Ubuntu 24.04. Setting a strong password for the root user follows next. This credential allows direct login as the root user when administrative tasks demand it.

Run this `sudo` command.

🐧Bash / Shell
sudo -s

Terminal prompts request the current password; enter it to proceed.

Advertisement

Next, execute the command that configures the root user's password.

🐧Bash / Shell
sudo passwd root

Terminal prompts require entering and confirming a new password for the root account.

💻Code
New password: 
Retype new password:
passwd: password updated successfully

Configuring the root user password automatically enables the account.

Run the following command and enter the root password to switch your active command-line session (shell) to the root user.

Advertisement

The root user prompt on Ubuntu 24.04 displays "root" at the beginning and "#" at the end. This visual cue confirms operations run with the highest level of system privileges. This root status grants complete control over the entire Ubuntu 24.04 system.

💻Code
root@Ubuntu:~# 

Restrict the su command

To restrict the su command on Ubuntu and secure your system, you need to edit the Pluggable Authentication Modules configuration file for switching users. Restricting this command stops unauthorized local users from jumping into the administrator account even if they guess your password. You just edit a text file in the terminal to force users into a specific security group before they can run the switch user command.

Executing the command below opens the su configuration file.

💻Code
nano /etc/pam.d/su

Uncomment the highlighted line inside the file.

Advertisement
💻Code
# Uncomment this to force users to be a member of group adm
# before they can use `su'.
auth required pam_wheel.so group=adm

Save changes and exit the editor.

Granting permission to use the `su` command on Ubuntu 24.04 requires adding the target user to the `adm` group. Membership in this group permits switching to the root user, a powerful administrator account.

💻Code
usermod -aG adm richard

Configuration finishes here.

Summary:

Root access grants total control over every file and service. Treat this account with care to keep the operating system stable.

  • The root account offers full administrative access and can perform any task on the system.
  • By default, the root account is disabled to enhance security.
  • You can easily enable the root account using the sudo command to set a password.
  • Limiting the use of the su command helps prevent unauthorized access to the root account.
  • Always ensure that only trusted users are added to the adm group to maintain system integrity.
  • Regularly review user permissions and access to the root account to ensure ongoing security.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 Related Tutorials

How to Install Additional Software on Ubuntu
Ubuntu Linux How to Install Additional Software on Ubuntu
How to Enable UAC Administrator Display in Windows 11
Windows How to Enable UAC Administrator Display in Windows 11
How to Install NetData on Ubuntu 24.04
Ubuntu Linux How to Install NetData on Ubuntu 24.04
How to Install Let's Chat on Ubuntu Linux
Ubuntu Linux How to Install Let's Chat on Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *