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.
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
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:
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:
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.