How to Change the Root Password in Linux
Method 1 of 2:
With the Current Root Password
- Open a terminal window. To do so, press Ctrl+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.
- Type su at the command prompt, and press ↵ Enter.[2] A Password: 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, run su and try again.
- Passwords are case-sensitive.
- Type passwd and press ↵ Enter. An Enter 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.'
- Type exit and press ↵ Enter. This will log you out of the root account.
Method 2 of 2:
Without the Current Root Password
- Restart your computer.
- Press E at 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 press E before 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 with linux /boot. Use the ↑ and ↓ keys to do so. This is the line you'll need to modify in order to boot into single-user mode.
- In CentOS and some other distributions, the line may begin with linux16 rather than linux.
- Move the cursor to the end of the line. Use the →, ←, ↑, and ↓ keys to place the cursor right after ro.
- Type init=/bin/bash after ro. The end of the line should now look like this:
ro init=/bin/bash
.- Note the space between
ro
andinit=/bin/bash
.
- Note the space between
- Press Ctrl+X. This tells the system to boot directly to a root-level command prompt in single-user mode.
- Type mount –o remount,rw / at the prompt and press ↵ Enter. This mounts the file system in read-write mode.
- Type passwd at the prompt and press ↵ Enter. Since booting into single-user mode gives you root access, there's no need to pass additional parameters to the passwd command.
- 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.'
- Type reboot –f and and press ↵ Enter. This command reboots the system normally.
3.7 ★ | 3 Vote
You should read it
- How to Bypass Windows 7 Password
- 106 tips with Microsoft Office - Part 3
- How to prioritize to enter the passcode interface when opening iPhone
- How to Install JDK in Linux
- How to automatically enter passwords in Android
- How to Install Gnome on Arch Linux
- Press type in C
- How to Reset Administrator Password on Windows
May be interested
- 2 steps to change Linksys wifi passwordif you find that your home wi-fi connection is slowing down recently, even if the charges are increasing for unknown reasons, then it is possible that your home wi-fi network has been stolen. the only solution is to quickly change your wifi password. in the article below, we will guide you to change linksys wifi password. please consult.
- Error on macOS allows creating root account without passwordrecently, an error in the latest version of macos high sierra allows users to create a root account without a password by repeatedly clicking on the button in the options panel.
- How to change your computer, phone and Mac passwordschanging a new password (password) on your computer and phone will help you absolutely protect your data and prevent unauthorized people from accessing it when you're not around.
- How to change VNPT WiFi passwordchange vnpt wifi password you need to pay attention to the type of modem you are using, depending on each vnpt modem but how to change the wifi pass vnpt is also different. here are the specific instructions for you guys.
- How to change Apple ID password?in the following article, we will walk you through the basic steps to change your apple id account information, which is used to access and use mac services for the user community.
- Linux Error SUDO allows you to run commands as roota flaw in the sudo linux command has been discovered, which may allow non-privileged users to execute commands as root.
- How to manage user passwords from Terminal in Linuxlike many things on linux, passwords are easily managed directly from the command line. the passwd utility is designed to allow you to quickly and easily access all password-related commands on the system. you can use it to change and manage your password and other user passwords on the system
- Instructions for changing Viettel WiFi modem passwordthe operation of changing viettel wifi password is essential, to be able to secure personal wifi, as well as to ensure the internet connection speed is stable.
- Learn the file system and folders on Linux operating systemslinux and unix file systems are organized in a hierarchy similar to the structure of a hierarchical tree. the highest level of the file system is the root directory, denoted by a slash '/' (root directory).
- Change your Facebook password on your phone, how to change mk fbchanging your facebook password on your phone is not the same as changing the pass face on your computer, because the facebook interface on the web and on the mobile app is a bit different. below tipsmake.com will guide you how to change your facebook password on the phone application.