Theme editor

How to Change the Root Password in Linux

Aior

Administrator
Staff member
Joined
Apr 2, 2023
Messages
83
Reaction score
2
Points
8
Age
39
Location
Turkey
Website
aior.com
How to Change the Root Password in Linux

Sometimes you need to change the root user’s password for security or administrative reasons. Below is a simple guide to do this on a standard Linux distribution, written in a XenForo-friendly format.

  1. Log in or Switch to the Root User
    If you are not already logged in as root, you can switch to the root account via su -:
    Bash:
    su -
    Enter the current root password when prompted. If you are already logged in as root, skip this step.
  2. Use the “passwd” Command
    To change the root password, simply run:
    Bash:
    passwd
    It will prompt you to enter a new password and then confirm it:


    Code:
    New password:
    Retype new password:

    Make sure you use a strong password (mix of letters, numbers, and special characters).
  3. Verify the Change
    Once the change is successful, you should see a message like:

    Code:
    passwd: all authentication tokens updated successfully
    From now on, the new password will be required whenever you or anyone else attempts to log in as root.
  4. B Switching Back to Normal User[/B]
    If you need to return to a regular, non-root account, just type:
    Bash:
    exit
    This will drop you back to your previous user session.

Additional Tips
If you are unable to log in as root normally, some distributions disable direct root logins by default. You may need to use sudo passwd root instead of switching to root first.
Always remember to secure and protect the root user’s password carefully, as it grants full system control.

That’s all there is to it—after running passwd, your root password on Linux is successfully changed.
 

Featured content

Back
Top