ubuntu create new user code example

Example 1: create user ubuntu command line

sudo adduser USERNAME
# choose password
# other fields can be left empty
sudo usermod -aG sudo USERNAME

# change user to check if everything is ok
su - USERNAME
whoami
#  output > USERNAME
sudo whoami
# output > root or an error

# if error switch back to the other account
# and do the following to modify /etc/sudoers

sudo visudo
# find a line like "root ALL=(ALL:ALL) ALL" (or similar)
# add an identical line for USERNAME, like
# "USERNAME ALL=(ALL:ALL) ALL"
Ctrl+O, Ctrl+X  # save and exit
# change user to check if everything is ok

Example 2: how to make new user linux termil

sudo useradd -m username

#set user password
sudo passwd username

#add user to sudoers [DANGEROUS]
usermod -aG sudo username

Example 3: ubuntu adduser

sudo adduser username
sudo usermod -aG sudo username

Example 4: create user in linux

useradd [OPTIONS] USERNAME

Example 5: allintext:ubuntu "new user"command

sudo adduser userNameHere