Setting Up a Superuser on Ubuntu: A Quick Guide

Prince ShammahPrince Shammah
2 min read

Managing a system on Ubuntu often requires superuser privileges. If you're tired of googling "how to set up a superuser on Ubuntu" every time like me, here's a simple, step-by-step guide to get it done efficiently. Save this for future reference! Iโ€™m really just writing this for myself.


What is a Superuser?

A superuser, often referred to as "root," is a user account with unrestricted access to all system files and commands. It's essential for administrative tasks like software installation, configuration changes, and file system management.


Step 1: Access Your Terminal

You can open the terminal using:

  • Ctrl + Alt + T (keyboard shortcut)

  • Searching for "Terminal" in the application menu.


Step 2: Switch to Root

If your current user already has sudo privileges, you can switch to the root account temporarily by typing:

sudo -i

You'll be prompted to enter your password. After this, you'll be logged in as the root user.


Step 3: Create a New Superuser

  1. Add a new user by running:

     sudo adduser username
    

    Replace username with the desired username. You'll be prompted to set a password and provide optional details.

  2. Grant the user sudo privileges:

     sudo usermod -aG sudo username
    
  3. Test the new superuser by switching to the account:

     su - username
    

    Then, try using sudo:

     sudo apt update
    

Step 4: Enable Root User (Optional)

If you want to enable the root account directly (not recommended for security reasons):

  1. Set a password for the root account:

     sudo passwd root
    
  2. Enter and confirm the password.

To disable the root account later:

sudo passwd -l root

Step 5: Keep It Secure

  • Use strong, unique passwords for all superuser accounts.

  • Limit sudo privileges to trusted users.

  • Regularly update your system to patch vulnerabilities:

      sudo apt update && sudo apt upgrade
    

Summary Commands

Here's a quick reference:

  1. Add a user: sudo adduser username

  2. Grant sudo privileges: sudo usermod -aG sudo username

  3. Switch to root: sudo -i

  4. Enable root (optional): sudo passwd root

With these steps, you'll always have a reliable superuser setup for your Ubuntu system. Bookmark this post or save it in your notes so you won't have to Google it again! ๐Ÿ˜Š

0
Subscribe to my newsletter

Read articles from Prince Shammah directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Prince Shammah
Prince Shammah