Managing user accounts is one of the most basic system administration tasks on any Linux server. On Ubuntu 18.04, you can add, modify, and remove users directly from the command line using simple built-in tools.
This guide shows you how to add and delete users on Ubuntu 18.04 and how to grant a new user sudo privileges.
Prerequisite: You need root or sudo access to manage user accounts.
The adduser command creates a new user account and sets up their home directory automatically.
To add a new user named john:
bashsudo adduser john
The command walks you through a short setup process. It will ask you to set and confirm a password, then optionally fill in some basic profile details like full name and phone number. Press Enter to skip any field you do not want to fill in.
The new user’s home directory is created at /home/john, and a set of default configuration files is copied into it automatically.
By default, new users do not have administrative access. To give a user sudo privileges, add them to the sudo group:
bashsudo usermod -aG sudo john
To confirm the change worked, switch to the new user and run a command with sudo:
bashsu - johnsudo whoami
Output: root
If you see root, the user has sudo access.
To remove a user account without deleting their home directory and files:
bashsudo deluser john
If you want to remove the user and delete their home directory and all their files at the same time:
bashsudo deluser --remove-home john
Use the --remove-home flag carefully. Once deleted, those files cannot be recovered unless you have a backup.
To see a list of all user accounts on the system, print the /etc/passwd file:
bashcut -d: -f1 /etc/passwd
This shows every account, including system accounts. Regular user accounts typically start from UID 1000 and above.
User management on Ubuntu is straightforward once you know the right commands. Use adduser to create, usermod to modify, and deluser to remove accounts. Got questions? Leave a comment below.
VirtualBox is a free, open-source, cross-platform virtualization application maintained by Oracle. It lets you run multiple…
PostgreSQL (also called Postgres) is a free, open-source, object-relational database management system with a strong reputation…
VMware Workstation Player is a mature, stable virtualization platform that lets you run multiple isolated operating…
A properly configured firewall is one of the most important layers of security for any internet-facing server. UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules that ships pre-installed on Ubuntu. Its defaults are sensible: block all incoming connections, allow all outgoing connections. No outside traffic reaches your server unless you explicitly open a port. This guide covers how to configure a UFW firewall on Ubuntu 18.04, from setting default policies and application profiles to writing allow and deny rules for specific ports, IPs, and subnets. <strong>Prerequisite:</strong> You need sudo access. Configure UFW Firewall on Ubuntu: Defaults, SSH, and Application Profiles If UFW is not installed, add it with: bashsudo…
UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules on Ubuntu. It ships pre-installed…
Apache Cassandra is a free, open-source NoSQL database designed for high availability and linear scalability with…