Blog

How to change root password on CentOS Linux

I am a new user of CentOS Linux servers. I need to change the password for root user account on CentOS Linux. How do I change the root password on CentOS Linux using command line options?

Introduction – You need to use the passwd command. It is used to update the user’s authentication token(s) i.e. password. Let us see how to change the root user password on CentOS Linux.

How to change root password on CentOS Linux

The procedure for changing the password of root is as follows:

  1. First, log in to the CentOS Linux server using ssh or console
  2. Open a shell prompt and type the passwd command to change root password in CentOS Linux
  3. The actual command to change the password for root on CentOS Linux is sudo passwd root

NOTE: Please note that {vivek@centos7:~ }$ is my shell prompt. You need to type commands after the $ prompt.

CentOS Linux change root password command

I am going to log in to my CentOS Linux 6.x/7.x/8.x server using the ssh command:
{vivek@centos7:~ }$ ssh vivek@centos7-server
Once logged in enter the command passwd as follows:
{vivek@centos7:~ }$ sudo passwd root
First you need to type the password for vivek user. After that the passwd command asks for the new password, which you will have to enter two times:

Changing root account passwords on an CentOS Linux based system

The next time you log in to a CentOS Linux server/workstation, use the new password.

Slightly different procedure for changing passwords in CentOS Linux

One can use the following procedure too:
{vivek@centos7:~ }$ ssh user@your-centos-server-name-ip
Become a root user via the su command or sudo command:
{vivek@centos7:~ }$ sudo -i
OR
{vivek@centos7:~ }$ su -
Finally change your root user password:
passwd

Conclusion

To change your own password on a CentOS, run:
passwd
Set up a new password for root:
sudo passwd root
And to change password for any other users:
sudo passwd userName
sudo passwd tom

This page explained the process for changing the password of root user using the passwd command on a CentOS Linux.

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Related posts

Australian Banks Westpac and ANZ Experiment With Ripple

Viking Coin

Self-signed SSL Certificate Warnings

Viking Coin

Hungary’s 220volt Now Accepts Bitcoin for Laptops, Tablets, TVs and More

Viking Coin

Changing Exchanges: Will the Coinbase of Tomorrow Be Decentralized?

Viking Coin

Coinbase to Enable Ethereum Classic Withdrawals

Viking Coin

Reviewed: Xapo’s Bitcoin Debit Card

Viking Coin

Seedcoin: Incubator Brings Bitcoin Startups to the World

Viking Coin

West Virginia Lawmakers Want to Make Bitcoin Money Laundering a Felony

Viking Coin

NiceHash CEO Confirms Bitcoin Theft Worth $78 Million

Viking Coin