Table of Contents
This updated guide examines How to Change the Root Password in Linux and organizes the essential facts, background, and practical takeaways in clear American English.
Responsible-use note: Apply security techniques only to systems you own or are explicitly authorized to test.
Method 1of 2:
With the Current Root Password
Open a terminal window. To do so, pressCtrl+Alt+T,[1]which will open a new terminal window with a command prompt in most Linux desktop environments.
- If you're not using a desktop environment, you're already at a command prompt, so proceed to the next step.
Typesuat the command prompt, and press?Enter. [2]APassword:line will open below the command prompt.
Type the current root password, then press?Enter. When the password is accepted, you'll be brought back to the command prompt as the root user.
- If you type the password incorrectly, runsuand try again.
- Passwords are case-sensitive.
Typepasswdand press?Enter. AnEnter new UNIX password:line will appear below the prompt.
Type a new password and press?Enter. The password you type will not appear on the screen.
Retype the new password and press?Enter. You will see a message that reads 'password updated successfully.'
Typeexitand press?Enter. This will log you out of the root account.
Method 2of 2:
Without the Current Root Password
Restart your computer.
PressEat the Grub menu. [3]The Grub menu appears right after you turn on the computer. In most cases, it only stays on the screen for a few moments.
- If you don't pressEbefore the Grub menu disappears, reboot and try again.
- This method works for most popular Linux distributions (Ubuntu, CentOS 7, Debian). There are many distributions of Linux, some more obscure than others. If you're not able to get to single-user mode with this method, check your distribution's website for instructions specific to your system.
Scroll to the line that begins withlinux /boot. Use the?and?keys to do so. This is the line you'll need to modify to boot into single-user mode.
- In CentOS and some other distributions, the line may begin withlinux16rather thanlinux.
Move the cursor to the end of the line. Use the?,?,?, and?keys to place the cursor right afterro.
Typeinit=/bin/bashafterro. The end of the line should now look like this: ro init=/bin/bash.- Note the space between
roandinit=/bin/bash.
- Note the space between
PressCtrl+X. This tells the system to boot directly to a root-level command prompt in single-user mode.
Typemount –o remount,rw /at the prompt and press?Enter. This mounts the file system in read-write mode.
Typepasswdat the prompt and press?Enter. Since booting into single-user mode gives you root access, there's no need to pass additional parameters to thepasswdcommand.
Type a new root password and press?Enter. The characters you type won't be displayed on the screen. This is normal.
Retype the new password and press?Enter. When the system confirms you've re-entered the same password, you'll see a message that reads 'password updated successfully.'
Typereboot –fand and press?Enter. This command reboots the system normally.
FAQ
What is How to Change the Root Password in Linux about?
It provides a structured overview of password, explains the main context, and highlights practical takeaways for readers.
Why does this topic matter?
Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.
How should readers use this information?
Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.
Reader Comments 0
Sign in with email or Google to join the discussion.