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:
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:
Replace username
with the actual user’s name.
3. Verify the Changes
Log in as the user and try switching to root using:
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:
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: