Ubuntu: Changing Root Password
This post will guide you how to change root password on Ubuntu Linux. How do I reset Root password on Ubuntu Linux 16.04/18.04.
Changing Root Password
The root user account is locked in Ubuntu Linux by default. so you do not use root user to login the Ubuntu Linux by default. and if you want to run program or command as a superUser, and you need to use su command. If you want to change root password, you need to use sudo command with passwd command to achieve it. Just use the following command:
$ sudo passwd root
Outputs:
devops@devops-osetc:~$ sudo passwd root sudo: unable to resolve host devops-osetc [sudo] password for devops: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
then you can use su command to change the current logging user as root. Type:
# su root
Outputs:
devops@devops-osetc:~$ su root Password: root@devops-osetc:/home/devops# whoami root
If you want to disable your root account for security on Ubunt Linux, you can use the following command:
$ sudo passwd -dl root
This command will quickly disable a password for root account.