Objective
The objective is to set a root password on Ubuntu 18.04 Bionic Beaver LinuxOperating System and Software Versions
- Operating System: - Ubuntu 18.04 Bionic Beaver Linux
Requirements
Privileged access to to the system usingsudo
command is required. Conventions
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
sudo
command - $ - requires given linux commands to be executed as a regular non-privileged user
Other Versions of this Tutorial
Ubuntu 20.04 (Focal Fossa)Instructions
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 thesudo
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 thesudo -i
command. Consider the following example: 
Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.
Set root password
The followingsudo
command will allow you to set the root password: $ sudo passwdFollow 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. 