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

What Is a Data Protection Platform and Why Your Organization Needs One

A data protection platform is a unified system that helps organizations discover, classify, monitor, and…

4 days ago

How Swiss Privacy Rules Affect AI Companies Under GDPR

AI companies operating in or around Switzerland face a compliance challenge that most legal teams…

5 days ago

Swiss FADP vs EU GDPR: Key Differences for AI and Data Privacy

Two major data privacy laws now govern how organizations handle personal data across Europe; the…

6 days ago

Kali Linux Commands Cheat Sheet: Complete Quick Reference

This cheat sheet covers the essential Kali Linux commands every pentester and ethical hacker uses…

1 month ago

What I Wish I Knew Before Learning Malware Analysis and Reverse Engineering

When I first started learning malware analysis and reverse engineering, I thought the hardest part…

1 month ago

git fetch vs git pull: How They Work and When to Use Each

Both git fetch and git pull talk to a remote repository, but they do very different things to your…

2 months ago