(blog-of ‘Alex’)

A personal blog about software development and other things. All opinions expressed here are my own, unless explicitly stated.

How to: Create new user from Linux 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, use real user in place of USERNAME in the script above.