The objective of this guide is to access the root shell and optionally change the default root blank password on Ubuntu 20.04 Focal Fossa Linux.
In this tutorial you will learn:
- How to execute Linux commands with administrative root privileges
- How to change to root shell
- How to set root password
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Installed or upgraded Ubuntu 20.04 Focal Fossa |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
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 |
Access root shell on Ubuntu 20.04 Focal Fossa Linux step by step instructions
By default Ubuntu system ships with a blank root password. This means there isn’t a way to access root’s shell via the su
command. This is not a fault but security measure. Users, are not expected to login as root and all commands which are required to be run under administrative privileges should be executed by the sudo
prefix of the command itself. Example:
$ sudo mycommand Password:
The following steps will explain how to set a root password on Ubuntu 20.04 Linux and thus gain a permanent access to root’s shell using the su
command and the root password. Having a root password my be needed to access your Ubuntu system remotely via SSH.
- First step is to use
sudo
to set a root’s password:$ sudo passwd
Another alternative is to become root first and then set the root password. Example:
$ sudo -i Password: # passwd
- Access the root shell or login via SSH using the new root's password:
$ su Password:
- Once you are in the root's shell confirm that you are logged in as root:
# whoami root