When you initially set up your server, you will only have root access. For security purposes logging directly into your server as root should be disabled. Since root login will be disabled, in this article we will go over how to disable root access and creating new users so that you may access your server.
- Ubuntu server
- Root access
First, you need to disable root login access. You want to disable this access to prevent any malicious actors from brute-forcing the password and thus gaining root access to your server. With root access, hackers will be able to do all kinds of nasty things that may run up the CPU usage, which will cost you a lot of money.
sudo passwd -l root
Now that root login is disabled, when you want to log into the server you will do so as a user (that we will create next), then sudo up to the root user when you need root access.
sudo adduser username
When you need to switch to the root user you can run the following command.
Deleting users is done with the following command.
sudo deluser username
Note: when you run this command you will also need to delete the home folder for that user
You can create a group by running this command.
sudo addgroup groupname
To delete a group run the following command.
sudo delgroup groupname
When you create a group and you want to add users to that group you can run this command.
sudo adduser username groupname
We have gone over how to disable root login access, create and delete users, create and delete groups and adding users to said groups.