How to create a sudo user – System user
In most of our guides, we use the root user to deploy software. This is because we create a new virtual server for use when creating the guide. Most users won’t have the luxury of a clean server to install software to so for security it’s best practice to use a sudo user and not the root user of the server.
SUDO users are users with administrative permissions on your system. These users use their own username and password to login to the server and run tasks just like the Root user would.
It is advised to create a SUDO user to manage your server rather than using the root account. You can disable root logins once you have a working SUDO user. This would make it harder for a malicious user to compromise your server because they would not know which user has root permissions. In this article, we will show you how to create a SUDO user.
Create a SUSO user using the usermod command
First things first! always update your system. Make it a rule of thumb that every time you log in to your server you run a yum update. This way your system will always be kept up-to-date.
The usermod command adds users to the Wheel group of users and on CentOS systems, this group of users already has administrative privileges.
First, create a new user which you will use as your SUDO user
adduser First2Host
Then, create a password for this user
passwd First2Host
Finally, add the user to the Wheel group using the usermod command. Users in the Wheel group already have administrative privileges.
usermod -aG wheel First2Host
You can now use the SU command to switch to this user and test that user does indeed have administrative privileges.
su First2Host
Then, try to list some files in the root directory. Remember, you need to place sudo in front of any commands you run.
sudo ls -la /root
Or try installing nano to your system
sudo yum install nano -y
Providing your new SUDO user works you can then proceed to restrict access to the root account. If you plan to change your SSH settings to prevent root logins why not also change your SSH port to increase the security of your system whilst you are in that file. Changing your SSH port can reduce the threat of a server compromise by over 50%.
Video Tutorial – Create a SUDO User
How was this article? – How to create a sudo user – System user
[kkstarratings]
More from Linux VPS Servers
How to configure additional IPs in a Debian 11 VPS
On Debian 11 instances, we removed the /etc/network/interfaces file and now configure interfaces using Cloud-init on boot. Discovery will send …
How to update Ubuntu 20 LTS to Ubuntu 22 LTS
Many people will be using LTS (Long Term Support) versions of Ubuntu. These LTS versions are great for developers because …
2 Comments
[…] Create a system user (sudo) […]
[…] should be using a SUDO user on servers. If you have not created a SUDO user you should do this […]