It’s a good idea to change your passwords regularly and consider using enterprise password management software.
This guide will help you change your Linux root password in Ubuntu or CentOS, or reset the password.
- A computer running Linux
- Command-line interface (terminal)
- Introduction
- Temporary Switching to root
- Changing Root Password
- Conclusion
- Option 1: Changing Ubuntu Password in the Command Line
- Option 2: Change sudo Password with the passwd Command
- Option 3: Changing Ubuntu Password Using GUI
- Change user password in Ubuntu [Command Line]
- Change (or set) the root password in Ubuntu
- Change Ubuntu password using GUI
- More on user passwords in Linux
- 1: How to enable Ubuntu root Login Temporarily?
- 2: How to enable root user in ubuntu via Graphical User Interface?
- 3: How to enable ubuntu root in Command-line?
- Conclusion
- What is root user? Why is it locked in Ubuntu?
- How to run commands as root user in Ubuntu?
- How to become root user in Ubuntu?
- How to enable root user in Ubuntu?
- See Password Status Info
- See Password Status Info for All the Accounts
- Change a User Password
- Delete User Password
- Expire Account Password
- Set Number of Days After the Password Expires and the Account Deactivates
- Set the Minimum Number of Days Between Password Changes
- Set the Maximum Number of Days for Which the Password Remains Valid
- Change the Expired Password
- Display the Warning for Expiring Password
- Lock the Password
- Unlock the Password of an Account
- Use the Quiet Mode
- Change Password for Repository Named “Repo”
- Change the Root Directory for the passwd Command Process
- See All passwd Commands
- Reset Ubuntu password from recovery mode
- Step 1: Boot into recovery mode
- Step 2: Drop to root shell prompt
- Step 3: Remount the root with write access
- Step 4: Reset username or password
- Possible Troubleshoot:
- Alternate method to reset Ubuntu password
- Step 1
- Step 2
- Step 3
- Step 4
- If resetting Ubuntu passwords is this easy, isn’t this a security risk?
- Bonus Tip: Handling the possible keyring issue after changing the password
- Did it help you?
- How to change Ubuntu root password?
- How to change the Ubuntu default password using the command line?
- How to change default root password Ubuntu using GUI?
- How to reset the default ubuntu password ?
- How to reset Ubuntu’s root password from Recovery Mode
- How to switch a root user account in Ubuntu
- Sudo Users
- What are Ubuntu default login credentials?
- What is the Ubuntu Default Root Password?
- How to enable root account in Ubuntu?
- How to disable your root user account in Ubuntu?
- Advantages and Disadvantages of Ubuntu
- Conclusion
- Сбрасываем пароль от root через GRUB
- Changing Your Root Password in Ubuntu
- Step 1: Open a Terminal Window
- Step 2: Change Your Root Password
- Changing the Root Password in CentOS
- Step 1: Access the Command Line (Terminal)
- Step 2: Change the Password
- Step 1: Access Boot Menu
- Step 2: Edit Boot Options
- Step 3: Remount the Drive
- Step 4: Changing the Password
- Step 5: Restart
- Resetting a Root Password in Ubuntu
- Step 1: Boot to Recovery Mode
- Step 2: Drop Out to Root Shell
- Step 3: Remount the File System with Write-Permissions
- Step 4: Change the Password
Introduction
Temporary Switching to root
sudo command-name
sudo su -
whoami
Output
root
Changing Root Password
sudo passwd root
The new root password will be required to be entered and confirmed.
Make sure you use a strong and unique password when creating the password. The most critical part of your account’s security is having a strong password. A strong password often consists of at least 16 characters, one uppercase letter, one lowercase letter, one number, and one special character.
When you type the password, it does not appear on the screen.
Output
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
That’s it. The password for the root account has been updated.
You can now use the new password to log in to your Ubuntu system as root.
Conclusion
The root account in Ubuntu has no password by default. To run commands with root capabilities, the sudo command is advised.
You’ll need to set the root password before you can log in as root.
If you have any queries, please leave a comment below and we’ll be happy to respond to them.
ROOT-пользователь — это пользователь с правами администратора, созданный по умолчанию в Linux-системе (Ubuntu). Root аналог администратору в ОС Windows, который имеет доступ ко всему в системе.
Этот способ предполагает вход в систему Ubuntu под пользователем с sudo правами, а команда «su» разрешена как часть «sudo» привилегий.
sudo su
Глядя на скриншот выше, можно заметить смену пользователя на «root», таким образом, мы вошли в Ubuntu под root, используя свой пароль.
Теперь мы можем сменить пароль root-пользователя, для этого необходимо использовать следующую команду:
passwd
После ввода команды указываем новый пароль в запросе «New password» и повторяем новый пароль после запроса «Retype new password».
Пароль для root будет установлен при первом использовании команды или изменит его на новый пароль при дальнейших использованиях команды «passwd».
А работает ли новый пароль? Давайте это выясним, нажимаем сочетание клавиш «Ctrl+D», чтобы окончить текущий ввод данных в терминале, либо запускаем новый терминал и вводим новую команду:
su
Данной командой мы войдем в систему как root, после чего вводим новый пароль, который мы только что установили для root.
Таким образом мы успешно изменили пароль от root.
Are you looking to change the root password in Ubuntu?
Changing passwords is a good practice and should be done periodically.
There are three (3) ways to change passwords in Ubuntu.
The first two (2) options use the command line, and the other uses Linux’s graphical interface (GUI).
- Ubuntu installed and running
- A user with sudo privileges
- Access to a terminal/command line
- The apt-get tool, pre-loaded in Ubuntu and other Debian-based distros
Option 1: Changing Ubuntu Password in the Command Line
To change the sudo password using the sudo
command:
1. First, open the terminal using the keyboard shortcut CTRL+ALT+T.
2. Query for a password change by running the command:
sudo passwd root
You will be prompted to enter and verify a new password. The output will inform you the password was updated successfully.
Option 2: Change sudo Password with the passwd Command
1. First, open the terminal (CTRL+ALT+T).
sudo –i
Type in your current password and hit Enter. The output you receive should show that you can now run commands as root.
3. Next, change the password by running the command:
passwd
Type and retype a new password to verify the change.
exit
5. Exit out of the terminal with the same command:
exit
Option 3: Changing Ubuntu Password Using GUI
To change the default root password in Ubuntu without using the terminal or any commands, use the graphical interface.
1. Open the Activities overview by pressing the Windows or Super key.
2. Type settings in the search bar and click on the Settings icon.
3. In Settings, click on the Details card (which is most likely the last one).
5. This will open a new Change Password pop-up. Type in your current root password, your new root password and verify the new password by retyping it.
6. Once you have filled in all the fields, click Change to confirm the changes.
Finally, make sure that your password includes both lower and upper case letters, numbers and special characters. It is essential to have a strong password to prevent brute force attacks.
Why do you need to change the password in Ubuntu? Let me give you a couple of scenarios.
- Change user password via the command line
- Change root user password
- Change user password via GUI
Change user password in Ubuntu [Command Line]
If you want to change your current password, simply run this command in a terminal:
passwd
You’ll be asked to enter your current password and the new password twice.
You won’t see anything on the screen while typing the password. This is perfectly normal behavior for UNIX and Linux.
Sometimes, the passwd
command will throw errors like:
Small Password: If the new password is shorter than 8 characters
Fails Dictionary Check: Does not contain enough different characters. So, use some other characters than just numbers and try again.
sudo passwd <user_name>
If you changed your password and forgot it later, don’t worry. You can easily reset Ubuntu password.
Change (or set) the root password in Ubuntu
You can set or change root password using the passwd command. However, in most cases, you don’t need it and you shouldn’t be doing it.
Now, about changing the root password.
Else, you can change it using the existing root password.
sudo passwd root
Change Ubuntu password using GUI
I have used GNOME desktop with Ubuntu 22.04 here. The steps should be more or less the same for other desktop environments and Ubuntu versions.
Go to Overview (press Windows/Super key) and search for Settings.
Now, select Set password Now option on the dialog box and type and confirm the new password. If you are changing your own password, you’ll also have to enter your current password.
More on user passwords in Linux
Here’s a fun thing you can do with sudo so that it makes fun of you when you enter incorrect password.
And get familiar with the Seahorse password manager app in Linux desktops.
List of content you will read in this article:
If you are a newbie, you may be scratching your head about how to enable your root account in Ubuntu! Well, for several security purposes, the ubuntu root login account is kept disabled. Before we begin, here is some preface.
When you install Ubuntu, a root account is created. The issue here is that you do not have the provision to set the password for the account.
sudo grep root /etc/passwd
The x in the output signifies that the account’s password is empty.
sudo grep root /etc/shadow
- Temporary Method
- Command-Line and Graphical User Interface Method
- Command-Line Method
1: How to enable Ubuntu root Login Temporarily?
2: How to enable root user in ubuntu via Graphical User Interface?
Type root in the first textbox.
Type your root account password.
As soon as you type the password, you encounter an error message. The reason is that a security layer in the graphical interface stops any login until and unless several other configuration files are configured.
sudo cp /etc/gdm3/custom.conf /etc/gdm3/custom.conf_backup
sudo cp /etc/pam.d/gdm-password /etc/pam.d/gdm-password_backup
Now, simply, open the “/etc/gdm3/custom.conf” configuration file
sudo vi /etc/gdm3/custom.conf
Press save and exit.
Now, open “/etc/pam.d/gdm-password” which is a configuration file.
Just save and hit exit on the ‘gdm’ configuration file.
sudo reboot -f
As you have rebooted your system, login into the root account now.
You can log in to the root account easily.
sudo passwd -dl root
Reverse whatever changes you made in the two configuration files earlier.
Delete “AllowRoot=true” from the “/etc/gdm3/custom.conf” configuration file as shown below.
Next, delete the ‘#’ from “/etc/pam.d/gdm-password”.
And you are done!
3: How to enable ubuntu root in Command-line?
Using the command-line method, you can easily enable or disable the root account through the command line. Here, you cannot log in through a graphical interface.
sudo -i passwd root
su – root
sudo passwd -dl root
To be sure, switch to the root account and see if the process is successful.
su - root
If you see the same message as the above image, then yes, you have successfully disabled the account, as now you can see that the authentication has failed.
Conclusion
We hope that the article solved your queries and provided you with a better understanding of the topic. If you have any questions or suggestions, please leave them in the comment section below.
People are also reading:
Either you run commands with root privilege like this:
sudo any_command
sudo su
What is root user? Why is it locked in Ubuntu?
You don’t need to have root privilege for your daily tasks like moving file in your home directory, downloading files from internet, creating documents etc.
Take this analogy for understanding it better. If you have to cut a fruit, you use a kitchen knife. If you have to cut down a tree, you have to use a saw. Now, you may use the saw to cut fruits but that’s not wise, is it?
Does this mean that you cannot be root in Ubuntu or use the system with root privileges? No, you can still have root access with the help of ‘sudo’ (explained in the next section).
How to run commands as root user in Ubuntu?
apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
So, how do you run commands as root? The simple answer is to add sudo before the commands that require to be run as root.
sudo apt update
[email protected]:~$ sudo apt update
[sudo] password for abhishek:
If you are absolutely new to Linux, you might be surprised that when you start typing your password in the terminal, nothing happens on the screen. This is perfectly normal because as the default security feature, nothing is displayed on the screen. Not even the asterisks (*). You type your password and press enter.
Bottom line:
To run commands as root in Ubuntu, add sudo before the command.
When asked for password, enter your account’s password.
When you type the password on the screen, nothing is visible. Just keep on typing the password and press enter.
How to become root user in Ubuntu?
The sudo command allows you to simulate a root login shell with this command:
sudo -i
[email protected]:~$ sudo -i
[sudo] password for abhishek:
[email protected]:~# whoami
root
[email protected]:~#
You’ll notice that when you switch to root, the shell command prompt changes from $ (dollar key sign) to # (pound key sign). This makes me crack a (lame) joke that pound is stronger than dollar.
sudo su
If you try to use the su command without sudo, you’ll encounter ‘su authentication failure’ error.
exit
How to enable root user in Ubuntu?
sudo passwd root
Again, this is not recommended and I won’t encourage you to do that on your desktop. If you forgot it, you won’t be able to change the root password in Ubuntu again.
sudo passwd -dl root
I hope you have a slightly better understanding of the root concept now. If you still have some confusion and questions about it, please let me know in the comments. I’ll try to answer your questions and might update the article as well.
This article shows examples of how to use the passwd
command in Linux, along with all the available options.
- Access to the terminal
- Superuser or root privileges (sudo)
Note: To check if you have sudo privileges, type sudo whoami
in the terminal.
The general command is:
passwd <options> <username>
See Password Status Info
Using passwd
with the --status
option displays all the information about a password and the validity periods. The shorter version is -S
:
passwd --status
passwd -S
sudo passwd -S <username>
The password status has seven fields:
The last three fields are in days.
See Password Status Info for All the Accounts
Check the status info for all accounts using passwd
with the sudo command with the -S
and -a
options, or the extended version --all
:
sudo passwd --status --all
sudo passwd -S -a
Change a User Password
sudo passwd <username>
Delete User Password
sudo passwd --delete <username>
sudo passwd -d <username>
When you check the password status, it changes the second field from P to NP:
The passwd --delete
and passwd -d
commands are a quick way to disable a password for an account.
Expire Account Password
To force expire a password use the --expire
or -e
options with the passwd
command:
sudo passwd --expire <username>
sudo passwd -e <username>
Set Number of Days After the Password Expires and the Account Deactivates
An account can automatically deactivate after its password has expired and not changed for a certain number of days. Use the -i
or --inactive
option and set the number of days as an integer:
sudo passwd --inactive <number of days> <username>
sudo passwd -i <number of days> <username>
Set the Minimum Number of Days Between Password Changes
To change the minimum number of days between password changes, use the --mindays
or -n
option with the number of days as an integer:
sudo passwd --mindays <number of days> <username>
sudo passwd -n <number of days> <username>
Set the Maximum Number of Days for Which the Password Remains Valid
To change the maximum number of days between password changes, use the --maxdays
or -x
option with the number of days as an integer:
sudo passwd --maxdays <number of days> <username>
sudo passwd -x <number of days> <username>
Change the Expired Password
Once a password expires, a prompt appears during next login to change the password. Enter the old password and then a new one twice for confirmation. In this example, the expiry was root enforced:
Display the Warning for Expiring Password
The warning period message displays for expiring passwords. Use the option --warndays
or -w
to set how many days before the expiry the warning appears:
sudo passwd --warndays <number of days> <username>
sudo passwd -w <number of days> <username>
Lock the Password
sudo passwd --lock <username>
sudo passwd -l <username>
Unlock the Password of an Account
To unlock a password for a locked account (L), use the --unlock
or -u
option:
sudo passwd --unlock <username>
sudo passwd -u <username>
Use the Quiet Mode
passwd --quiet
passwd -q
Change Password for Repository Named “Repo”
sudo passwd --repository <repository> <username>
sudo passwd -r <repository> <username>
Change the Root Directory for the passwd Command Process
The passwd
command process runs from the default root directory. Modify the root directory by running the --root
option:
sudo passwd --root <directory path>
Or the -R
option:
sudo passwd -R <directory path>
You need to set a password for root for the information update.
See All passwd Commands
There are numerous commands to use with the passwd
tool. List all the options if you forget any by running:
passwd --help
passwd -h
A list of all the options along with a short description prints out:
If you find it hard to keep track of all the different passwords and changes, there are many enterprise solutions for password management.
Forgot your Ubuntu login password? It happens.
If you haven’t used Ubuntu for some time, it’s only natural to not remember the password. The good news is that you don’t need to reinstall the entire operating system because of it. You can recover Ubuntu passwords easily.
The method mentioned here works for resetting an Ubuntu password in VMware, dual boot or single install. All you need is a little bit of patience and to run a couple of commands. You’ll reset the root password within minutes.
Reset Ubuntu password from recovery mode
Step 1: Boot into recovery mode
Switch the computer on. Go to the grub menu. Generally, it appears automatically – if not, then hold down the shift key or press Esc key until the boot menu appears.
If you’re using Oracle VirtualBox or VMware, you have to hold down the shift key when the logo of Oracle or VMware appears.
In the grub menu, select the “Advanced Options for Ubuntu”:
In here, you’ll see the option to go to recovery mode:
It will bring you to a black screen with several lines of output being displayed in a flash. Wait for a few seconds here.
Step 2: Drop to root shell prompt
Now you’ll be presented with different options for recovery mode. Here you need to choose “Root – Drop to root shell prompt“. Just press the enter key to select this option. Like in the picture below:
You’ll see that when you select the root shell prompt option, an option to enter commands appears at the bottom. This is your root shell prompt and this is where you’ll use the commands to reset the password.
Step 3: Remount the root with write access
You need to have write access to the root partition. By default, it has read-only access.
Use the command below to remount it with write access:
mount -rw -o remount /
Step 4: Reset username or password
ls /home
passwd username
It prompts for a new password. Enter the new password twice.
Do note that nothing is displayed on the screen when you start typing the password. This is perfectly normal and actually a security feature in Linux systems. Just blindly type the password and press enter.
Enter new UNIX password:
Retype new UNIX password:
Voilà! There you go. You have just successfully reset the password. Now exit the root shell prompt:
exit
When you exit, you’ll be back at the recovery mode menu. Select the normal boot option here.
There will be a warning about graphics mode compatibility. Don’t worry. A complete reboot will fix any issues with this.
You should now be able to log in with the new password.
Possible Troubleshoot:
While entering the new password you might be prompted with Authentication token manipulation error like this:
mount -rw -o remount /
Now try to reset the password again. It should work now.
As you can see, it is extremely easy to change Ubuntu password even if you’ve forgotten it. It will barely take a few minutes.
Alternate method to reset Ubuntu password
If for some reason you have difficulty dropping to the root shell and changing the password, you can try these steps.
Step 1
Reboot your computer. Hold shift to bring up the grub screen (if it doesn’t appear automatically). Press E at the grub prompt to edit the grub screen.
Step 2
Find the line starting with linux, change the ro to rw and append init=/bin/bash at the end of that line.
Step 3
Press ctrl-x to save your changes and boot.
In other words, your system will boot up to a passwordless root shell.
Step 4
Set your new password.
Once you’ve set the new password, exit the terminal. Just type reboot in the terminal or use the shutdown command.
shutdown -r now
Your password should be changed now.
If resetting Ubuntu passwords is this easy, isn’t this a security risk?
That’s a fair question. One of the main advantages of Linux over Windows is its security. But if “anyone” can reset the password, how come Ubuntu or other Linux distributions can be considered secure?
Let me explain a few things here. The main security risk is if someone hacks into your account from a remote location via the internet. That’s not happening here.
If anyone has physical access to your computer, the data in your computer is already at risk. Unless the entire disk is encrypted, anyone can “steal” your data using a live USB without even entering your installed operating system.
This lack of root password is a deliberate feature The “advanced options for Ubuntu” in the boot menu allow you to perform some specific root-related tasks from the “root shell prompt”. This is why you’re able to reset the Ubuntu password through this method.
Bonus Tip: Handling the possible keyring issue after changing the password
There is a keyring feature in Ubuntu that is used for keeping passwords locked and safe.
When you reset the forgotten password, the keyring remains unlocked and you may see an error message like this.
Open the Passwords and Keys application and here, delete the Login passwords.
When you try to use Google Chrome again in Ubuntu, it will ask you to create a new keyring. Use the new login password as the keyring password.
Did it help you?
I hope I made things clear about resetting forgotten passwords in Ubuntu.
List of content you will read in this article:
How to change Ubuntu root password?
- Open the terminal by pressing Ctrl+Alt+T or searching for «Terminal» in the Ubuntu Dash.
- Type the command «sudo passwd root» and press Enter. You will be prompted to enter your current user password.
- After authenticating, you can set a new password for the root user. Make sure to choose a strong and secure password.
- Retype the new password when prompted to confirm.
- Once the password change is successful, you can exit the terminal.
How to change the Ubuntu default password using the command line?
- Launch the terminal by pressing Ctrl+Alt+T or searching for «Terminal» in the applications menu.
- To change the root password, you need administrative privileges. Execute the following command to access root privileges: sudo -i
- Once you have root privileges, enter the following command to change the root password: passwd
You will be prompted to enter a new password. Make sure to choose a strong and secure password that includes a combination of uppercase and lowercase letters, numbers, and special characters. Note that the password will not be visible as you type.
- After entering the new password, you will be prompted to confirm it. Re-enter the password carefully, ensuring it matches exactly as you intended.
- If the password change is successful, you will receive a confirmation message. Your Ubuntu system’s root password is now updated.
Remember to keep your root password confidential and avoid using easily guessable information. Regularly changing your passwords enhances the overall security of your Ubuntu system.
How to change default root password Ubuntu using GUI?
- Launch the Terminal: Open the Terminal by clicking on the Applications menu, typing «Terminal» in the search bar, and selecting the Terminal application.
- Access User Accounts: Type «sudo gnome-control-center user-accounts» command in the Terminal and press Enter. This command will open the User Accounts settings.
- Authenticate: Enter your user password when prompted to authenticate your access.
- Modify Root Account: In the User Accounts settings, select the » root » account and click the «Password» button.
- Set New Password: Enter the new password for the root account in the provided fields. Make sure to choose a strong and secure password.
- Apply Changes: Click on the «Change» or «Apply» button to save your changes to the root password.
- Confirm Changes: Close the User Accounts settings and log out of your session. To apply the new root password, you need to log back in using the updated credentials.
Remember, changing the root password in Ubuntu enhances the overall security of your system by preventing unauthorized access. Ensure you choose a unique and robust password to maintain the integrity of your Ubuntu installation.
How to reset the default ubuntu password?
Forgot your Ubuntu login password? If you haven’t used Ubuntu for a long time, and now you want to login in, and you don’t remember your password. So here is the method to reset your Ubuntu Password. You quickly get your password, and you don’t even need to reinstall it.
How to reset or change root password:
Open up the terminal!
After opening the terminal, type the command sudo space passwd space root
- [ Sudo passwd root ] & press enter
- Enter the new root password and press Enter button
- Retype root password and enter
- Password changed successfully
To verify your new password, use this command.
- su root & press Enter key
- Now Enter the new given password of your Ubuntu and press Enter Key
Now you can use your new Ubuntu Root Password. You have successfully made a new password to the Ubuntu root terminal.
How to reset Ubuntu’s root password from Recovery Mode
- Start or restart your Ubuntu system.
- When the GRUB boot menu appears, select the advanced options for Ubuntu and choose the recovery mode option. If you don’t see the GRUB boot menu, you may need to press and hold the Shift key during startup to make it appear.
- In the recovery mode menu, select the option that says «root Drop to root shell prompt.» This will drop you into a root shell with root privileges.
- Remount the file system in read/write mode by running the following command:
mount -o remount,rw /
- Next, you need to change the root password. Use the following command to set a new password:
You will be prompted to enter the new password twice. Note that when you type the password, it won’t be visible on the screen for security reasons. Press Enter once you’ve entered the new password.
- After setting the new password, you can reboot your system by running:
Remember to keep the root password secure and make sure to remember it or store it in a safe place.
How to switch a root user account in Ubuntu
Sudo Users
The first time you use Sudo, you will be prompted to enter the password. If you want to run the command with sudo without entering the password, you must edit the sudoers file.
What are Ubuntu default login credentials?
What is the Ubuntu Default Root Password?
How to enable root account in Ubuntu?
1. Open a terminal: Press `Ctrl + Alt + T` on your keyboard to open a terminal window.
sudo passwd root
4. Next, you will be asked to enter the new password for the root account. Type your desired password and press Enter. Please note that while typing the password, no characters will be displayed on the screen for security reasons.
5. Confirm the new password by typing it again and pressing Enter.
How to disable your root user account in Ubuntu?
- Open a terminal on your Ubuntu system.
- Run the following command to set a password for the root account (if you haven’t already done so): sudo passwd root
You will be prompted to enter and confirm a new password for the root account.
- Once the root password is set, run the following command to lock the root account: sudo passwd -l root
This command locks the root account, effectively disabling it.
Advantages and Disadvantages of Ubuntu
Here you can find the pros and cons of using Ubuntu leaving root logins disabled by default, includes:
- People often forget their login passwords occasionally (the root password).
- It avoids the access of «I can do anything» login by default. It will prompt for a password earlier; the changes can happen!
- Sudo adds a log access of the command(s) run (in /var/log/auth.log). In case you were in trouble, you can go to the authorities and run.
- Every cracker trying to brute-force their manner in on a server will know it has an account named root and could try that first.
- What they do not know is the usernames of your other users. Due to the fact that the root account password is locked, this attack doesn’t pose any threat at all as there may be no password to crack or guess inside the first location.
- Allows easy transfer of admin rights by adding or removing users. When you use only one Ubuntu root password, you could change the root password if you forgot.
- Sudo may be set up with a safety policy.
Automatically the authentication expires after some time (you can also set the time duration). So if you walk away or leave your desktop a few times from the terminal after running commands as root using sudo, you will not be leaving a root terminal open indefinitely.
Conclusion
You can also add special characters to your password. Add up to at least 16 characters with upper, and lowercase letters and numbers. It is how we can change the default root password.
Сбрасываем пароль от root через GRUB
Существует еще один способ для изменения пароля от root или любого другого пользователя при загрузке Ubuntu.
Сначала перезагружаем наш ПК. Если меню GRUB не появляется автоматически, то удерживаем клавишу «Shift» во время загрузки. Это принудительно откроет меню GRUB.
Затем выбираем пункт «Ubuntu» в меню и нажмите клавишу «E», чтобы начать редактирование конфигурации загрузки.
Далее необходимо внести изменения в строку, заменяем значение:
quiet splash $vt_handoff
rw init=/bin/bash
Результат отображен на скриншоте ниже:
Изменения заключаются в том, чтобы из GUI перейти в оболочку Bash для внесения изменений — смена пароля. Нажимаем клавишу «F10», чтобы загрузиться с новой конфигурацией.
Загрузка с измененной конфигурацией сработает только один раз и сброситься при повторной загрузке.
Мы вошли в систему как root-пользователь в командной строке. Теперь используем команду для сброса пароля:
passwd
Указываем и повторяем новый пароль.
Затем перезагружаем систему в обычном режиме (без GRUB) и входим как root уже с новым паролем.
Changing Your Root Password in Ubuntu
Step 1: Open a Terminal Window
Right-click the desktop, then left-click Open in terminal.
Alternately, you can click Menu > Applications > Accessories > Terminal.
Step 2: Change Your Root Password
sudo passwd root
The system will prompt you to enter your password – this is the same password you use to log in to the system.
Next, the system will prompt you to enter a new password. Do so, and then re-enter it exactly the same when the system prompts you to retype the password. This double-entry confirms that you have typed the password correctly.
Changing the Root Password in CentOS
Changing a password in CentOS is almost identical to changing it in Ubuntu.
Step 1: Access the Command Line (Terminal)
Right-click the desktop, then left-click Open in Terminal. Or, click Menu > Applications > Utilities > Terminal.
Step 2: Change the Password
sudo passwd root
This is a similar process as in Ubuntu, with a couple of variations.
Step 1: Access Boot Menu
Restart the system, then tap the Esc key about once per second to launch the GRUB menu.
Step 2: Edit Boot Options
Use the arrows to highlight the version of Linux you boot into, then press e.
Use the arrows to highlight the line that starts with kernel or Linux.
Step 3: Remount the Drive
mount / -o remount,rw
Step 4: Changing the Password
passwd
Press Enter, and the system should prompt you to enter and confirm a new password.
Step 5: Restart
mount / -o remount,ro
sync
reboot
Your system should restart. Confirm that your new password works by logging in.
Note: If you ever come across a Linux boot failure, be sure to save our guide on using GRUB rescue to troubleshoot it.
It can be more challenging if you’ve lost or forgotten a password, but with a little creative restarting and editing, you shouldn’t find it too hard.
Resetting a Root Password in Ubuntu
In some situations, you may need to access an account for which you’ve lost or forgotten a password.
Step 1: Boot to Recovery Mode
Restart your system. Once you see the splash screen for the computer manufacturer, hold down the shift key. The system should come up with a black and white GRUB, or boot menu, with different Linux kernel versions displayed.
Step 2: Drop Out to Root Shell
The system should display a menu with different boot options. Use the arrow keys to navigate to the option labeled root and press Enter.
The system should respond by giving you a command-line interface with a prompt.
Step 3: Remount the File System with Write-Permissions
Right now, your system only has read-only access to your system. That means it can look at the data, but cannot make any changes. But we need write-access to change the password, so we’ll need to remount the drive with the appropriate permissions.
At the prompt, type:
mount –o rw,remount /
Press Enter. This should allow you to make changes to the data on the hard drive.
Step 4: Change the Password
At the prompt, type:
passwd username
shutdown –r
Hit Enter, and your system should restart. Don’t press any keys, let the system come up to the login screen, and test to make sure the new password works.
Note: Learn how to use the chpasswd command. Chpasswd is helpful for managing multiple passwords and making multiple changes.