Before we go any further, this is not to reset your root password when you have lost or forgotten it. This is to change your current root password to a new one. The guide below assumes you know your root password to begin with.
Operating System: CentosOS Linux
The steps to change your root password is a quick and easy one.
SSH to your server.
SSH firstname.lastname@example.org (replace with server IP)
Enter current password when prompted
Once logged in successfully, use the following command line
sudo passwd root
Follow the prompts that appear
New password: Retype new password: passwd: all authentication tokens updated successfully.
That’s it. It’s that easy. Now, make sure you don’t lose your new password. If you have to save this somewhere, keep it safe.