Add a Linux System User

Last modified: 
Tuesday, May 17th, 2016
# As root...
# Add the user and set a password.
useradd <uname>
passwd <uname>

# Add a public ssh key for a remote user.
mkdir /home/<uname>/.ssh
echo <> >> /home/<uname>/.ssh/authorized_keys
chown -R <uname>:<uname> /home/<uname>/.ssh
chmod 700 /home/<uname>/.ssh
chmod 600 /home/<uname>/.ssh/authorized_keys

# Add user to the sudoers file to gran sudo access with password prompt.
sudo visudo
## Add this after root    ALL=(ALL)       ALL
<uname>    ALL=(ALL)       ALL

# Or add user to the wheel group to grant sudo ALL 
# without a password prompt.
usermod -aG wheel <uname>

See Also

The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.