Ubuntu: add user from the shell

The following script does the trick:

sudo su - // elevate priveleges to the superuser
useradd -d /home/USERNAME USERNAME // create user with home dir
passwd USERNAME // set password for the user
chown USERNAME /home/USERNAME // grant priveleges for using the home dir
chsh -s /bin/bash // specify to use bash when the user logs in

Words in uppercase implies user-specified values, e.g. instead of USERNAME type the login name of the user you wish to add.

Leave a Reply

Your email address will not be published. Required fields are marked *