Most new Linux CentOS 8 admins don’t know how to reset or change sudo password from command line environment. For security reasons, it is recommended that you regularly change the password for each user on the system. This habit is important for the superuser, who has special privileges to perform all important tasks in CentOS 8. Only the superuser or superuser can change the password for any other account. Regular users can only change their passwords. User password can be changed on CentOS 8 using the passwd command.
This article shows how the root user can change his password on CentOS 8.
To change the sudo password from the command line, follow these steps:
Step 1. Open Terminal
To change the sudo user password, you must first open a command prompt or terminal on your CentOS 8 system. To do this, you can use the keyboard shortcut “Ctrl + Alt + t” to open a terminal, or you can access it from the tool’s search bar launch applications as follows:
You can open the app launcher search bar by pressing the window key or the superscript key on your keyboard.
Step 2. Log in as administrator or root user.
The root user can only change his own password. Therefore, log in as root on your CentOS 8 system. To do this, you need to type the following command in a terminal:
$ sudo -i
The system will prompt you for your root account password. Enter your password and press “Enter” to log in as root.
You are logged in as root on your CentOS 8 system. You can see this in the image above.
Step 3. Change the sudo password using the passwd command.
Now that you are logged in as root, you can change the password for the root account by running the passwd command as follows:
After running the passwd command in the terminal, the system warns you about changing the current root password and prompts you to enter a new root password. You enter a new password and press “Enter”, the system will again prompt you to enter a new password. Enter the above password again and press Enter. The terminal will display a confirmation message that all authentication tokens have been successfully updated, which means the password has been successfully updated.
Now use the updated password for your root account in all software installation and file configuration operations that require root authorization.
Step 4. Log out or end your root terminal session.
Now that you have changed the root password, you can exit the root user prompt by typing the following command:
After executing the above command, the terminal will display a logout status, which means that you are logged out or logged out of the root account.
There is another alternative for changing the root password. You use the following command on the terminal, with which you log in as root and enter the password for the root account. With a single command, you can change the root password this way.
$ sudo passwd root
After executing the above command, a notification about password change will appear on the terminal. Now enter your new password and press “Enter”. Enter the newly selected password again and press Enter again. After that, a message will appear stating that all authentication tokens have been successfully updated, which means that the root password has been changed.
In this article, you learned how to change the root password using the terminal on CentOS 8. I hope you can now change your root password to help protect your system from malicious activity. Please leave us your feedback in the comments.
How to change sudo password via command line in CentOS 8