By default, the root user account password is locked in Ubuntu Linux for security reasons. As a result, you can not login using root user or use a command such as ‘su -‘ to become a SuperUser.
You need to use the passwd command to change the password for user accounts on Ubuntu Linux. A typical user can only change the password for his/her account only. A SuperUser (root) can change the password for any user account. Your user account info stored in /etc/passswd and an encrypted password stored in /etc/shadow file.
How to change root password in Ubuntu
The procedure to change the root user password on Ubuntu Linux:
- Type the following command to become root user and issue passwd:
sudo -i
passwd - OR set a password for root user in a single go:
sudo passwd root - Test it your root password by typing the following command:
su –
A note about root password on an Ubuntu server/desktop
Enabling the root account by setting the password is not needed. Almost everything you need to do as SuperUser (root) of an Ubuntu server can be done using $ sudo systemctl restart apache2
You can add an additional user to $ sudo adduser {userNameHere} sudo
For example, add a user named $ sudo adduser pankaj sudo