Unix User Setup
Hey there! In this post I will quickly describe how one can create a new user on a unix system e.g. Ubuntu / server. You will create the user itself, assign its home folder and setup root privileges if needed.
This how-to has been tested on Ubuntu Server 18.04.2 LTS.
As a root user, the following steps need to be completed to create a new User with the name
Create home directory
Create user and add to group
useradd -g users -d /home/newuser -s /bin/bash newuser
Set the password for the user
newuseras the owner of his home directory.
chown newuser:root /home/newuser
Set the permissions for the home directory. Only allow
newuserto write in
/home/newuser. Others can read.
chmod 754 /home/newuser
Root / Sudo privileges
If the user
newuser should be able to use sudo and execute commands as root, the sudo file needs to be updated. The
sudo file can be updated by executing the following command.
The default sudo file includes at least the following line(s):
Copy this line and replace
root by the name of the new user. Here
newuser ALL=(ALL:ALL) ALL
If everything has been done correctly, the new user should now be able to login and also execute commands as sudo.
Thanks for reading!