Ubuntu 18.04 Bionic Beaver installation comes with a blank root password as default. This is a security precaution as user is expected to never login as the root user. For any privileged administration tasks the user is required to use the sudo command.
Login as Root
Setting a root password comes with risks, hence if possible you should try to avoid it. If you only need to gain a temporary command line root access this can be achieved with the sudo -i command. Consider the following example:
SUBSCRIBE NEWSLETTER & RSS Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.
Set root password
The following sudo command will allow you to set the root password:
$ sudo passwd
Follow the prompt to enter and retype the new root password. Once the root password is set use the su command to gain root shell access. The whole procedure is illustrated below.