It is recommended to avoid using root account frequently and this does cause trouble when admins suddenly would like to connect to a box under root account. One of the best ways to recover a forgotten root password is to use another account that has sudo privilege and can reset password for root. I am using my own account ‘nick’ in the below example:
Log on as ‘root’ and then create ‘nick’ account with strong password
Open visuo by running the below command
And then like you are using VIM, add one line at the bottom of the file
nick ALL=(ALL) ALL
You can log off ‘root’ and log on as ‘nick’ now and type
sudo su -
Then you become ‘root’ immediately and by using
you can easily re-set password for ‘root’.
All above 3 steps are well tested on CentOS. Hopefully this can be helpful.