change root password

How to Change Root Password in CentOS, RHEL, Fedora Linux

Sometimes you may need to change root password in your Linux system. There are a couple of ways to do this in CentOS, RHEL, Fedora Linux. In this article, we will learn how to change root password in CentOS, RHEL, Fedora Linux.


How to Change Root Password in CentOS, RHEL, Fedora Linux

You can change root password in CentOS, RHEL, Fedora Linux. Please not, in order to be able to change root password in Linux, you need to have sudo privileges or have the actual root password.


1. Change Password using passwd

Here is the simplest way to change password. You will be asked for new password. In this case, you don’t need to have existing root password.

$ sudo passwd

Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

If you want to change root password, you may alternatively run the following command.

$ sudo passwd root

It is advisable to use a strong password for root accounts, which contain uppercase & lowercase alphabets, numbers & special characters.

Once you have changed the password, you can try logging in as root and new password.

$ su -
Password:
[root@localhost ~]#


2. Change Root Password using su

If you are not sudo, still you can change root password using su command. In this case, first switch to root user. You will need to provide existing root password for this purpose, unlike while using sudo user above.

$ su -
Password:
[root@localhost ~]#

Once you have switched to root user, run the passwd command as shown below.

$ passwd

Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Once you have changed root password, you can logout of root account, back to your main account, be pressing Ctrl+D.

In this short article, we have learnt couple of simple ways to easily change root password in CentOS, RHEL, Fedora Linux.

Also read:

How to Ping Specific Port in Linux
How to Count Number of Files in Directory
How to Increase Your Security on Internet
How to Encrypt Partition in Linux
How to Encrypt Folder in Linux

Leave a Reply

Your email address will not be published.