Basic user management in Ubuntu

Posted on January 3, 2020
Tags: server, bash

List all users on the system

cut -d: -f1 /etc/passwd

source

Add a new user

sudo adduser <new_username>

or:

sudo useradd <new_username>

See also: What is the difference between adduser and useradd?

Remove a user

userdel <username>

Change username

To modify the username of a user:

usermod -l <new_username> <old_username>

Change a user’s password

To change the password for a user:

sudo passwd <username>

Add a user to a group

To add a user to the sudo group:

usermod -aG sudo <username>