root user is super powerful. With it, you can do anything to the system. Certainly, it is convenient to use, but it is considered bad practice because of security reasons. It could also lead to a fatal loss if you make a mistake with the
root user. Instead, it is better to use a non-root user with
sudo privilege to manage your system. Here is how to create one.
- Create a new user, enter the password and its confirmation. If you are asked any additional information, you can fill it or just leave it.
- Add the created user to
usermod -aG sudo johndoe
Now, you can log in to the system using
johndoe user and its password.
If you want to confirm whether the created user is in
sudo group, use the following command:
It will list the groups
johndoe belongs to.
If necessary, you can also copy the SSH Key Authentication of the
root user so that the created user can also log in using ssh key. To do so, use the following command:
rsync --archive --chown=johndoe:johndoe ~/.ssh /home/johndoe
Note: Above, we assume that you are logged in as the