The objective of this tutorial is to set a root password on Ubuntu 20.04 Focal Fossa Linux

In this tutorial you will learn:
  • How to set root password
How to set a root password on Ubuntu 20.04 Focal Fossa Linux
How to set a root password on Ubuntu 20.04 Focal Fossa Linux

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
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

How to set a root password on step by step instructions

WARNING
Ubuntu 20.04 installation comes with a blank root password as default. This is a security precaution since the user is never expected to login as the root user. For any privileged administration tasks the user is recommended to use the sudo command.

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.

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  1. To set a root password open up a terminal window and execute the following sudo command. First, you need to enter your user password ( given that you are part of the sudo administration group ) after which enter and retype a new root password :
    $ sudo passwd
    [sudo] password for linuxconfig: 
    New password: 
    Retype new password: 
    passwd: password updated successfully
    
  2. All done, you should now be ready to login with a new root password. Try it now: $ su password:
  3. Use the whoami command to confirm that you are logged in as a root user:
    # whoami
    root
    
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.