As soon as you have created your droplet or VPS, you should add a regular user for yourself too. This is important, since you do not want to run your server as root.
The root has simply too much power. A short moment of distraction, or even a typo, when entering a command can have disastrous repercussions for the health of your VPS.
It is much safer to add a regular Linux user and do the necessary administration work while you are logged in as a regular Linux user.
In this post we going to create such a user for John Doe – or Jane Doe if you like.
Unless you have added one or more SSH Keys when you created the VPS, your host e-mailed you a root password. Login as a root with either a SSH Key or the password.
When you sign in over SSH as a root, you are welcomed by the prompt:
The # sign in the prompt indicates that you are logged in as the root.
The # is usually referred to as the number sign or hash, but also known as pound, or octothorpe (eight points).
To create a user with the name jdoe, we use the
adduser command. Actually a small, interactive script.
You append the name of the user that you want to create. In this example that is jdoe.
So, type at that prompt:
The script will ask you to enter some details regarding user jdoe.
The password is mandatory, all other details are optional.
Besides the password, I suggest that you enter at least the Full Name of the user concerned.
The entire interaction looks like this:
root@vps:~# adduser jdoe Adding user 'jdoe' ... Adding new group 'jdoe' (1001) ... Adding new user 'jdoe' (1001) with group 'jdoe' ... Creating home directory '/home/jdoe' ... Copying files from '/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for jdoe Enter the new value, or press ENTER for the default Full Name : John Doe Room Number : Work Phone : Home Phone : Other : Is the information correct? [Y/n] root@vps:~#
Whenever the systems offers you a number of options to enter, the default option – here ‘Y’ – is capitalized.
When everything is correct, hit the <return> key or enter ‘y’.
Done. You have added user jdoe.
When a regular Linux user like jdoe logs in, the system response like this:
Instead of the hash, regular users see a dollar sign in the prompt.
So whenever you see the # in the prompt, be extra careful what you enter.
Change a User’s Password as Root
As the root, you can change a user’s password anytime.
To alter for example the password for John Doe, you enter:
The system will ask you to type and retype the new the password.
That is it.
Change a Your Password as User
Most users want to be sure that nobody knows his password. Not even the system administrator.
That is why a user is always able to change his own password. Simply by entering:
First, the user needs to enter the current password to verify the identity of the user.
After that, the system will ask the user to enter the new password – twice.
Changing password for jdoe. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
When the user reenters the existing password, the system will reply with:
Adding or changing a password for the root works exactly the same way, but only when logged in as the root or a user with root privileges.