//add user
sudo useradd [username]
or
//Use the -m to create the user home directory as /home/[username]
sudo useradd -m [username]
//if need to set password
sudo passwd [username]
#Changing password for user.
#New password:
#Retype new password:
#passwd: all authentication tokens updated successfully.
//add to sudo
//for centos
usermod -aG wheel username
//for ubuntu
usermod -aG sudo username
//add ssh key to signin
make file to /home/[username]/.ssh/authorized_keys
then add public key into that file. Done.
//sometime, you create an user and you can login successfully, but you can't use common command (e.g. tab auto/vi...)
When you add a user with useradd there is no special shell added.
You can see this with the command:cat /etc/passwd
The new user is no special shell added.
To fix this you can:
chsh -s /bin/bash [the new username]
and the "/bin/bash" just reference the root one.