How to Enable Root User on Ubuntu 24.04

This article explains how to enable the root user account on Ubuntu 24.04.

The root account on Ubuntu is the superuser account with all the power and unrestricted access to all commands and files on the system. It can execute any administrative task, install and remove software, change all configurations, and manage everything.

The root account gives you direct access to all administrative functions without needing to use sudo each time.

By default, the root account on Ubuntu is disabled because the account password is not set.

A user account that is a member of the administrator group can use the command to access root privileges. This is a safe and secure way to minimize risks.

If you prefer to use the root account to manage your system, the steps below walk you through how to enable it.

Enable root

The user account added during installation is set an administrative account that can use the sudo command. It’s easy to use this account to enable the root user account.

To enable the root account, run this sudo command.

sudo -s

Type your password when prompted.

Then, run the command to set the root user password.

sudo passwd root

When prompted, enter and confirm a new password for the root account.

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

With the root user password set, the account is automatically enabled.

Run the command below and type the root password to switch to the root user.

su -

You will know it’s the root user when the prompt begins with root and ends with #.

root@Ubuntu:~# 

Restrict the su command

When you enable the root account, you should also restrict who can use the [su] command to switch users including root.

To do that, run the command below to open the su config file.

nano /etc/pam.d/su

Uncomment the highlighted line in the file.

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

Exit and save.

Then, add the user who should be allowed to use the su command to the [adm] group.

usermod -aG adm richard

That should do it!

Conclusion:

Enabling the root user account on Ubuntu 24.04 can provide you with powerful administrative capabilities. However, it is important to proceed with caution to ensure system security. Here are the key takeaways:

  • 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.

Frequently Asked Questions

How do I enable the root user on Ubuntu 24.04?

To enable the root user on Ubuntu 24.04, open a terminal and run the command 'sudo -s' to gain root privileges. Then, set a password for the root account by executing 'sudo passwd root' and follow the prompts.

Why is the root account disabled by default on Ubuntu?

The root account is disabled by default on Ubuntu to enhance system security. This prevents unauthorized access and minimizes the risk of accidental changes or damage to the system.

What is the purpose of the 'su' command in Ubuntu?

The 'su' command allows a user to switch to another user account, including the root account, in the terminal. It is important to restrict its use to trusted users to maintain system security.

How can I restrict access to the 'su' command?

To restrict access to the 'su' command, edit the '/etc/pam.d/su' configuration file and uncomment the line that requires users to be a member of the 'adm' group. Then, add trusted users to the 'adm' group using the command 'usermod -aG adm username'.

What should I do after enabling the root account?

After enabling the root account, it's crucial to regularly review user permissions and access to maintain system security. Ensure that only trusted users are added to the 'adm' group and monitor any changes made with root privileges.

Categories:

Leave a Reply

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