(blog-of ‘Alex’)

My blog about software development and other things

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.