Changing your root password on a CentOS server
You can change your root password on your CentOS server via SSH with some simple commands whenever you need to by completing the following steps.
See also: Changing your root password on Plesk and cPanel.
Step 1
First, access the server via the SSH interface.
Step 2
If you are logged in as the root user, then you only need to type:
sudo passwd root
As shown in the example below:
[root@centos_server ~]# sudo passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@centos_server ~]#
Step 3
If you are logged in as a user that already has root permissions, then you will not need to type ‘sudo‘.
You can also set the ‘root’ to be a different user if you have multiple users set up.
In this case, you can type ‘passwd‘ alone and it will change the password for the current user.
Here’s an example of a use with root privileges changing their own password with the shorter command:
[root@centos_server ~]# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@centos_server ~]#