How to add or remove a user on your Linux server
Kort antwoord
Add a user with adduser username, add them to the sudo group with usermod -aG sudo username (Debian-based) or usermod -aG wheel username (Red Hat-based), and remove one with userdel -r username.
The commands for managing users are largely the same across distributions, with two small differences. On Red Hat-based systems (AlmaLinux, Rocky Linux, RHEL), adduser doesn't prompt you for a password, so you set one separately. On Debian-based systems (Debian, Ubuntu), adduser prompts for a password and some optional personal details as part of the same command.
Add a user
Create the account
This example creates a user called worldstream:
sudo adduser worldstreamSet a password (Red Hat-based systems)
On Red Hat-based distributions you aren't prompted for a password automatically, so set one with:
sudo passwd worldstreamAdd or remove a user from the sudo group
On Debian-based systems, add a user to the sudo group with:
sudo usermod -aG sudo worldstreamOn Red Hat-based systems, the equivalent group is wheel:
sudo usermod -aG wheel worldstreamTo remove a user from the sudo group on a Debian-based system:
sudo gpasswd -d worldstream sudoTo remove a user from the wheel group on a Red Hat-based system:
sudo gpasswd -d worldstream wheelRemove a user
To remove a user account:
sudo userdel worldstreamThis leaves the user's home directory in place. To remove the home directory and mail spool along with the account, add the -r option:
sudo userdel -r worldstreamCommands can vary slightly between distributions and versions, so check the man page for your system if a command above doesn't behave as expected. If you run into trouble managing users on your server, contact support.