If you forget your root password or want to update for some reason, and you have sudo right, you can use passwd with sudo to change the root password.

$ sudo passwd root
[sudo] password for onuryilmaz:
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

After change, test your new root password by typing the following command:

$ su -
Password:
Last login: Mon Jan 13 08:47:09 +03 2020 from 10.10.99.200 on pts/0
Last failed login: Sun Jan 19 14:51:21 +03 2020 from 10.10.10.16 on ssh:notty
There were 55839 failed login attempts since the last successful login.

Happy coding.


If you liked this post, you can share it with your followers on Twitter!