How To

Create Sudo User on Ubuntu for Secure Admin Access

Managing a Linux server becomes much safer when you Create Sudo User accounts instead of working directly as the root user. Ubuntu allows administrators to grant elevated privileges through sudo, which helps protect the system while maintaining full administrative control.

In this guide, you will learn how to create a new user on Ubuntu, assign sudo privileges, and verify administrative access using simple terminal commands.

Why You Should Create Sudo User Accounts

Using the root account for daily tasks increases security risks. A small mistake executed as root can damage the entire system instantly. Instead, Ubuntu recommends using standard user accounts with sudo permissions.

When you create a sudo-enabled account, every privileged command gets logged. As a result, administrators gain better visibility and accountability across the server environment.

Additionally, sudo access limits accidental system-wide changes because users must intentionally elevate privileges before running sensitive commands.

Create Sudo User on Ubuntu

Before starting, log in to your Ubuntu server as root or use an existing account with sudo access.

Create a new user by running:

adduser username

Replace username with your preferred account name.

Ubuntu will ask you to set a password and optionally provide user information like full name or phone number. You can skip optional fields by pressing ENTER.

Unlike low-level account tools, adduser automatically creates the user’s home directory and default shell environment. Therefore, it remains the preferred option for most Ubuntu administrators.

Add the User to the Sudo Group

After creating the account, the next step is to grant administrative privileges.

Run the following command:

usermod -aG sudo username

This command adds the user to the sudo group without removing existing group memberships.

Alternatively, Ubuntu also supports:

adduser username sudo

Both methods achieve the same result. However, usermod is commonly used in server automation scripts.

Verify Create Sudo User Permissions

Once the permissions are assigned, switch to the new account:

su - username

Next, test sudo access:

sudo whoami

If everything works correctly, Ubuntu returns:

root

This confirms the account now has elevated administrative privileges.

Common Sudo Troubleshooting Tips

Sometimes sudo access does not work immediately. In most cases, the issue comes from session caching.

Log out completely and sign back in after adding the user to the sudo group. You can also refresh group permissions using:

newgrp sudo

If Ubuntu displays sudo: command not found, install the sudo package first:

apt update && apt install sudo

Additionally, always double-check group membership with:

groups username

adduser vs useradd Explained

Ubuntu provides both adduser and useradd commands for account management.

adduser is interactive and beginner-friendly. It creates home directories automatically and simplifies account setup.

On the other hand, useradd offers lower-level control for scripts and automation tasks. However, it requires extra flags to create home directories and configure shells properly.

For most administrators, adduser remains the easier and safer choice.

Conclusion

Learning how to Create Sudo User accounts is one of the first and most important Ubuntu administration tasks. Instead of relying on the root account, sudo-enabled users provide stronger security, better auditing, and safer server management.

Whether you manage cloud servers, VPS deployments, or local Linux systems, using sudo properly helps maintain a cleaner and more secure environment.

Cyber Defence

Recent Posts

List Installed Packages on Ubuntu Like a Pro

Managing software on Linux becomes much easier when you know how to List Installed Packages…

2 hours ago

How To Use Variables In Bash Scripts

Introduction Variables are one of the most important basics of Bash scripting. A variable is…

20 hours ago

How To Run A Bash Script In Linux Step By Step

Introduction Running a Bash script in Linux is a basic but important skill for anyone…

20 hours ago

How To Write Your First Bash Script In Linux Step By Step

Introduction Writing your first Bash script in Linux is one of the best ways to…

20 hours ago

Install Docker on Ubuntu 24.04 With Easy Setup Guide

Docker has become one of the most important tools in modern software development. If you…

21 hours ago

APT Command Linux: Essential Package Management Guide

The APT Command Linux users rely on is one of the most powerful tools for…

1 day ago