CentOS is a Linux distribution based on and compatible with Red Hat's commercial Red Hat Enterprise Linux. A root account is a special Linux user account that has access to all files, all commands, and that can do just about anything and everything on a Linux server. In this instruction, we will tell you how to change the password on the Centos 8 operating system.This instruction will work for you in case you know the current password of the user account.
To change the root password in CentOS 8, you must have sudo privileges or have a valid root account password.
At the sudo -l
command prompt, run the command:
$ sudo –l
User may run the following commands on host-centos:
(ALL : ALL) ALL
Is this dialog box displayed? Then you should be able to change your current password. If you installed CentOS 8 with default settings, you may have decided to lock the root account by default. Changing the root password will unlock the account.
passwd
:
$ sudo passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Next, enter and confirm the new password.
To connect as the root user in CentOS 8, use the "su
" command without arguments:
$ su -
Password:
[root@localhost ~]#
Another method to change the password is with the su
command.
Connect as root:
$ su -
Password:
root@host-centos:~#
Now run the command "passwd
" without any arguments:
$ passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
This completes the instruction.