How to Change Root Password in Linux

This TipsMake article shows how to change the root password in the Linux operating system, applicable in cases where you remember your current password or cannot remember your root password.

In case you remember the current root password

images 1 of How to Change Root Password in Linux
Images 1 of How to Change Root Password in Linux

Open a terminal window. To open this window, press Ctrl+ Alt+ T, to open a new terminal window containing Command Prompt (command line interpreter) in most Linux desktop environments.

If you're not using the desktop environment, you're already using Command Prompt, so go to the next step.

images 2 of How to Change Root Password in Linux
Images 2 of How to Change Root Password in Linux

Type suin Command Prompt, then press ↵ Enter. The line Password:will open below the Command Prompt.

images 3 of How to Change Root Password in Linux
Images 3 of How to Change Root Password in Linux

Type in your current root password, then press ↵ Enter. Once the password is approved, you will return to Command Prompt as the root user.

If you type the wrong password, run suand try again.

Passwords are case sensitive.

images 4 of How to Change Root Password in Linux
Images 4 of How to Change Root Password in Linux

Type passwdand press ↵ Enter. The line Enter new UNIX password:will appear below the Prompt.

images 5 of How to Change Root Password in Linux
Images 5 of How to Change Root Password in Linux

Type a new password and press ↵ Enter. The password you type will not appear on the screen.

images 6 of How to Change Root Password in Linux
Images 6 of How to Change Root Password in Linux

Re-type the new password and press ↵ Enter. You will see the message 'password updated successfully'.

images 7 of How to Change Root Password in Linux
Images 7 of How to Change Root Password in Linux

Type exitand press ↵ Enter. This step helps you log out of the root account.

In case you don't remember the current root password

images 8 of How to Change Root Password in Linux
Images 8 of How to Change Root Password in Linux

Restart the computer.

images 9 of How to Change Root Password in Linux
Images 9 of How to Change Root Password in Linux

Click Ein the Grub menu. The Grub menu appears immediately after you turn on your computer. Normally, this menu only appears on the screen for a while.

If you can't press it Ebefore the Grub menu disappears, you'll need to restart your computer and try again.

This method can be applied to most popular Linux distributions (such as Ubuntu, CentOS 7, Debian). There are many Linux distributions available, some of which are not very well known. If you cannot switch to single-user mode using this method, you will need to visit your distribution's website for specific instructions for your system.

images 10 of How to Change Root Password in Linux
Images 10 of How to Change Root Password in Linux

Scroll down to the line starting with linux /boot. Press the and keys to do this. You need to edit this line to boot in single user mode.

In CentOS and some other distributions, the command line may begin with linux16instead of linux.

images 11 of How to Change Root Password in Linux
Images 11 of How to Change Root Password in Linux

Move the cursor to the end of the line. Press the , , , and keys to place the cursor immediately after ro.

images 12 of How to Change Root Password in Linux
Images 12 of How to Change Root Password in Linux

Type init=/bin/bashlater ro. Now the end of the line looks like this:
ro init=/bin/bash.

Notice the space between roand init=/bin/bash.

images 13 of How to Change Root Password in Linux
Images 13 of How to Change Root Password in Linux

Press Ctrl+X . This step causes the system to boot directly as a root-level Command Prompt in single user mode.

images 14 of How to Change Root Password in Linux
Images 14 of How to Change Root Password in Linux

Type mount –o remount,rw /in Prompt and press ↵ Enter. This step helps mount the file system in read-write mode.

images 15 of How to Change Root Password in Linux
Images 15 of How to Change Root Password in Linux

Type passwdin Prompt and press ↵ Enter. When booting in single user mode, you will have root access, so there is no need to write any additional parameters to the command passwd.

images 16 of How to Change Root Password in Linux
Images 16 of How to Change Root Password in Linux

Type in the new root password and press ↵ Enter. The characters you type will not be displayed on the screen. This is normal.

images 17 of How to Change Root Password in Linux
Images 17 of How to Change Root Password in Linux

Re-type the new password and press ↵ Enter. When the system confirms that you have re-entered the correct previous password, you will see 'password updated successfully'.

images 18 of How to Change Root Password in Linux
Images 18 of How to Change Root Password in Linux

Type reboot –fand press ↵ Enter. This command helps restart the system normally.

4 | 2 Vote
« PREV : How to Format USB on...
How to Install... : NEXT »