Creating User Through Command Line on Linux (Ubuntu 20.04)

Decorative header image for a Linux Ubuntu 20.04 guide

I am constantly forgetting how to create new users through the command line on Linux. This article is more for myself, than anyone else, so that I have something to refer to in the future rather than having to go and search down the page again elsewhere on the internet.

Adding new user, change USERNAME with the name you want to use.

adduser USERNAME
usermod -aG sudo USERNAME

# switch to user
su - USERNAME

Log out and log back in as new user. Be sure to add SSH key to new users ~/.ssh if using SSH to login.

Change directory user and group:

# changes recursively
sudo chown -R username:group directory

# changes only the directory
sudo chown username:group directory

To add zsh and OMZ:

sudo apt update
sudo apt install zsh
chsh -s $(which zsh)

Follow these instructions to install OMZ:

vim ~/.zshrc

# add:
alias l="ls --color -lahGg --group-directories-first --time-style='+ %a. %b %d %Y - %r '"
alias ll="ls --color -lah --group-directories-first"

# if the above does not work, run:
sudo apt install coreutils

# load in zshrc changes
source ~/.zshrc

Part of the guide: Docker and Linux

Looking for a senior developer? I'm open to new opportunities (opens in a new tab) or send an email .