Although it is conventional to log into the root account on some Linux systems, by default Ubuntu 22.04 does not allow us to log into root and instead expects us to achieve root permissions through use of
sudo. However, it is still possible to set a root password and subsequently log directly into root. In this tutorial, you will see how to set a password for the root account on Ubuntu 22.04 Jammy Jellyfish.
In this tutorial you will learn:
- How to set root password
- How to log into root account
|Category||Requirements, Conventions or Software Version Used|
|System||Ubuntu 22.04 Jammy Jellyfish|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to set a root password on step by step instructions
Ubuntu 22.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
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.
- To set a root password open up a terminal window and execute the following
sudocommand. 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
- All done, you should now be ready to login with a new root password. Try it now:
$ su password:
- Use the
whoamicommand to confirm that you are logged in as a root user:
# whoami root
In this tutorial, you saw how to set a root password on Ubuntu 22.04 Jammy Jellyfish Linux. This allows you to log directly into the root account, rather than only being able to access root permissions with the
sudocommand. Although it is a security recommendation to never use the root account, some administrators may be very accustomed to using it on other Linux distros and want the functionality on Ubuntu 22.04 as well.