The root password is an important task that you might need to perform on your Ubuntu machine. Whether you’re troubleshooting an issue, or you’re concerned about security, it’s important to know how to change root password in terminal ubuntu 22.04. In this tutorial, we will go through the process of changing the root password on Ubuntu 22.04.
Prerequisites
- Ubuntu 22.04 installed
- Administrator or root access
How to change root password in Ubuntu?
Step 1: Open the terminal
Open the terminal
by pressing Ctrl + Alt + T or by searching for it in the Applications menu to ubuntu change password.
Step 2: Use the passwd
command
Use the passwd
command to change the root password.
sudo passwd root
or
sudo -i
passwd
You will be prompted to enter your current root password, and then you will be prompted to enter the new password twice.
How to change root password in ubuntu server?
#ubuntu reset root password command line
sudo passwd
Step 3: Verify the new password
Verify that the password has been changed by logging out of your current session and logging back in with the new password.
su -
How to disable your root account on Ubuntu Linux?
To disable the root account on Ubuntu Linux, you can use the command sudo passwd -l root
. This command will lock the root account, preventing it from being used to log in or perform any actions on the system.
Alternatively, you can also edit the file /etc/shadow, and add an exclamation mark (!) at the beginning of the root line. This will prevent the account from being able to log in.
After disabling the root account, it is recommended to use a regular user account with sudo privileges for administrative tasks on the system.
To disable root password type:
sudo passwd -l root
The Short Note:
That’s it! You have successfully changed the root password on your Ubuntu 22.04 machine. It’s important to keep your root password secure and update it regularly to maintain the security of your system. If you have any questions or encounter any issues during the change process, feel free to leave a comment below.
Related blog: Force reinstall the package on Ubuntu.