Essential Ubuntu user management commands

Every single time I set up a new Ubuntu server, I need to create a bunch of groups & users. Instead of Googling for the same commands every time, I thought I’d save my future self some time and just list them here.

Also, here is a nice Digital Ocean article which I find useful as a reference when spinning up a new server.

List all users

cut -d: -f1 /etc/passwd

Add new user

adduser <username>

Add user to group

adduser <username> <group>

Check groups that a user belongs to

groups <username>

Login as another user

sudo su <username>
Sajad Torkamani

Hello! My name is Sajad. I’m a software developer at Nationwide and an aspiring entrepreneur. Originally from Afghanistan, I moved to London at an early age and have been living here for the past 20 years.

This is my personal website where I blog mostly about programming with occasional thoughts on a bunch of other things. I write mainly for my own benefit as I find that writing helps clarify my otherwise very confused thoughts.

Get in touch: