How to change root password on Fedora Linux

I am a new user of Fedora Linux version 28/29 servers. I need to change the password for root user account on Fedora Linux server. How do I change the root password on Fedora 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 Fedora Linux.

How to change root password on Fedora Linux

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

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

NOTE: Please note that [vivek@fedora-linux29:~ ]$ is my shell prompt. You need to type commands after the $ prompt.

Fedora Linux change root password command

I am going to log in to my Fedora Linux 27.x/28.x/29.x server using the ssh command:
ssh vivek@fedora-linux29
Once logged in enter the command passwd as follows:
[vivek@fedora-linux29:~ ]$ 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:

How to change root password on Fedora Linux

Changing root account passwords on Fedora Linux

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

Slightly different procedure for changing passwords in Fedora Linux

One can use the following procedure too:
[vivek@fedora-linux29:~ ]$ ssh user@your-centos-server-name-ip
Become a root user via the su command or sudo command:
[vivek@fedora-linux29:~ ]$ sudo -i
[vivek@fedora-linux29:~ ]$ su -
Finally change your root user password:

How do I change password for other users?

The syntax is:
sudo passwd userNameHere
sudo passwd vivek

How do I change my own password?

Simply type:


This page explained the process for changing the password of root user using the passwd command on a Fedora Linux. For more info see passwd command manual page by typing the following man command:
man passwd
passwd --help
Sample help page from Fedora Linux box:

Usage: passwd [OPTION...] <accountName>
  -k, --keep-tokens       keep non-expired authentication tokens
  -d, --delete            delete the password for the named account (root only); also removes password lock if any
  -l, --lock              lock the password for the named account (root only)
  -u, --unlock            unlock the password for the named account (root only)
  -e, --expire            expire the password for the named account (root only)
  -f, --force             force operation
  -x, --maximum=DAYS      maximum password lifetime (root only)
  -n, --minimum=DAYS      minimum password lifetime (root only)
  -w, --warning=DAYS      number of days warning users receives before password expiration (root only)
  -i, --inactive=DAYS     number of days after password expiration when an account becomes disabled (root only)
  -S, --status            report password status on the named account (root only)
      --stdin             read new tokens from stdin (root only)
Help options:
  -?, --help              Show this help message
      --usage             Display brief usage message

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum