How to Grant su (Superuser) Access to a User in Ubuntu

Published February 5, 2025
How to Grant su (Superuser) Access to a User in Ubuntu
Cheap Dedicated Server

How to Grant su (Superuser) Access to a User in Ubuntu

Introduction

In Ubuntu, regular users do not have superuser (su) access by default for security reasons. However, you can grant a user permission to switch to the root account using su. This requires adding them to the sudo group and setting a root password.


Steps to Grant su Access

1. Enable the Root Account (If Not Already Enabled)

Ubuntu disables the root account by default. To enable it, set a root password:

  Enable the Root Account

sudo passwd root

Enter and confirm a new password for the root user.

2. Add the User to the sudo Group

To allow a user to use su, they must have administrative privileges. Run the following command:

Add the User to the sudo Group

sudo usermod -aG sudo username

Replace username with the actual user’s name.

3. Verify the Changes

Log in as the user and try switching to root using:

Verify the Changes

su -

Enter the root password when prompted. If successful, the prompt will change to #, indicating root access.


FAQs

1. Why can’t I use su in Ubuntu by default?

Ubuntu disables the root account and encourages the use of sudo for security reasons.

2. How do I check if a user is in the sudo group?

Run:

groups username

If sudo is listed, the user has admin rights.

3. What’s the difference between su and sudo?

  • su switches to the root user after authentication.
  • sudo runs individual commands as root without switching users.

4. How do I disable root access again?

Lock the root account by running:

sudo passwd -l root

 


 

How to Grant su (Superuser) Access to a User in Ubuntu​ (F.A.Q)

 

Why can't I use su in Ubuntu by default?

Ubuntu disables the root account and encourages the use of sudo for security reasons.

How do I check if a user is in the sudo group?

Run:

groups username

If sudo is listed, the user has admin rights.

What’s the difference between su and sudo?

  • su switches to the root user after authentication.
  • sudo runs individual commands as root without switching users.

How do I disable root access again?

Lock the root account by running:

sudo passwd -l root