Tutorials  /  Linux Basics

Create and Manage Users in Linux: Standard & Sudo Guide

Ccentron Redaktion · August 2025 ·6 min read ·Linux Basics, Tutorial

Adding users in Linux allows you to set up individual accounts dedicated to specific tasks on a system. Regular users operate without special administrative permissions, while privileged users (sudo users) have full rights to execute administrative operations. Managing users helps maintain security, proper organization, and controlled access in a multi-user setup where each user has distinct credentials, permissions, and disk space.

This guide outlines the steps for creating both standard and sudo users in Linux, while also verifying user details to perform operations on your workstation.

Prerequisites

Before starting, ensure you have:

  • Access to a Linux instance either as root or as a user with sudo privileges.
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Create a User in Linux

To add users in Linux, you need superuser privileges. Depending on your distribution, you can use useradd or adduser. Below are the methods to create a non-root standard account using the useradd command.

Run the following command to create a user named example-user:

Console
$ sudo useradd -m example-user

This sets up a new user with a home directory.

On Debian-based systems like Ubuntu, use adduser for an interactive process:

Console
$ sudo adduser example-user

This command automatically generates a new group and a home directory. You will be prompted to enter a secure password.

To create a user without a home directory or shell login, use:

Console
$ sudo usermod -M -s /usr/sbin/nologin example-user

You can later edit /etc/passwd to assign a shell manually.

Set the new user password with:

Console
$ sudo passwd example-user

Enter and confirm a strong password. Example:

New password:
Retype new password:
passwd: password updated successfully

Check if the home directory exists:

Console
$ ls /home/

Output should include:

example-user  ....

Verify user details in /etc/passwd:

Console
$ cat /etc/passwd | grep example-user

Example output:

example-user:x:1001:1001::/home/example-user:/bin/sh

Explanation:

  • example-user: Username
  • x: Placeholder for encrypted password in /etc/shadow
  • 1001: User ID (UID)
  • 1001: Group ID (GID)
  • ::: User description
  • /home/example-user: Home directory
  • /bin/sh: Default shell

Create a Sudo User in Linux

A sudo user is a standard account with elevated privileges to run administrative tasks via sudo. This approach minimizes risk compared to using the root account directly. Follow these steps to create or convert a user into a sudo-enabled account.

Create a new user, for example linuxuser:

Console
$ sudo useradd -m linuxuser

On Debian-based distributions:

Console
$ adduser linuxuser

Grant sudo privileges using the usermod command:

On Debian/Ubuntu:

Console
$ sudo usermod -aG sudo linuxuser

On RHEL-based systems (CentOS, Rocky Linux, Alma Linux):

Console
$ sudo usermod -aG wheel example-user

On OpenSuse:

Console
$ sudo usermod -aG wheel example-user

In the above:

  • -aG: Adds user to a group without removing from others
  • sudo/wheel: Target group for administrative rights

Switch Users in Linux

You can switch accounts using the su (substitute user) command. Adding the - option loads the user’s environment and home directory. Non-sudo users require the password of the target account, while sudo su bypasses password prompts.

Switch to linuxuser with:

Console
$ su - linuxuser

Enter password when asked:

Password:

Details of the command:

  • su: Switches user
  • -: Loads profile and environment variables

Check sudo rights by listing /root directory:

Console
$ sudo ls /root

Enter the sudo password:

[sudo] password for linuxuser:

If the account has sudo rights, the command executes successfully. Otherwise, the attempt is logged and reported in system logs.

View User Information in Linux

In Linux, you can check user details such as username, groups, and ID values to help with tasks like modifying file permissions. Follow these steps to display the currently active user information on your workstation.

Run the whoami command to display the name of the logged-in user:

Console
$ whoami

Sample output:

linuxuser

Use the groups command to list all groups associated with a user:

Console
$ groups linuxuser

Example output:

linuxuser : linuxuser sudo

This confirms that the user linuxuser belongs to both the linuxuser and sudo groups.

Run the id command to view the user’s default group and related IDs:

Console
$ id linuxuser

This command shows the UID, GID, and all groups associated with the user. The GID indicates the default group.

Example output:

uid=1001(linuxuser) gid=1001(linuxuser) groups=1001(linuxuser),27(sudo)

Conclusion

You have successfully created users in Linux, including both standard and sudo accounts, secured with password authentication. You also verified user details such as username, groups, and IDs. Managing users effectively is key to ensuring security and organization on a Linux system. Always set strong passwords and grant sudo rights only to trusted individuals responsible for performing administrative operations like software installation.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren