How to change to root user in Ubuntu 22.04

After installing Ubuntu 22.04, you will inevitably be logging into the root account, or using administrator privileges, quite frequently. That’s because installing or removing software, as well as configuring system settings, requires the use of the root account or sudo command.

This isn’t just unique to Ubuntu, but actually all Linux systems. In this guide, we’ll show you how to change to the root account on Ubuntu 22.04 Jammy Jellyfish, and how to use sudo to execute commands with root privileges.

In this tutorial you will learn:

  • How to use sudo command
  • How to login to root account
  • How to open a terminal as the root user
How to change to root user in Ubuntu 22.04
How to change to root user in Ubuntu 22.04
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 22.04 Jammy Jellyfish
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

Change to root user in Ubuntu 22.04



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!

  1. In Ubuntu, usually you will just preface a command with sudo if you need to execute it with root permissions. You will be prompted for your password if you haven’t recently authenticated. Here’s an example:
    $ sudo apt update
    

    Using sudo to execute a command with root privileges in Ubuntu 22.04
    Using sudo to execute a command with root privileges in Ubuntu 22.04
  2. Alternatively, you can execute the sudo -i command to login to the root user account. Once logged in, you won’t need to use the sudo command at all.
    $ sudo -i
    

    Logging into the root user account on Ubuntu 22.04
    Logging into the root user account on Ubuntu 22.04

To confirm which user you are logged in as, you can execute the whoami command.

$ whoami
linuxconfig

Or when logged into root:

# whoami
root

Open terminal as root user




To open a terminal as the root user, usually you would just execute the sudo -i command inside a new terminal. If, instead, you want to open a brand new terminal as the root user, you can execute the following command:

$ sudo gnome-terminal
Opening a new terminal as root user in Ubuntu 22.04
Opening a new terminal as root user in Ubuntu 22.04

Conclusion

Knowing how to access the root account on your Ubuntu 22.04 system is absolutely essential if you want to carry out any type of system administration task. We went over a few options here, including the sudo command, or elevating directly to the root user account.