Project

General

Profile

To log in with sudo privileges

User documentation
13/02/2026

To log in with sudo privileges on Ubuntu 24.04, log in with your standard user and run commands using sudo , or switch to a root shell using sudo -i. To enable a user for sudo, add them to the sudo group using sudo usermod -aG sudo .

Methods to Gain sudo Access
Run Commands as sudo: Prefix any command with sudo to execute it with root privileges (e.g., sudo apt update).

Switch to Root Shell (sudo -i): Type sudo -i to switch to a root shell, which keeps your current user environment variables.

Switch to Root (sudo su -): Type sudo su - to become the root user, loading the root user's environment.

Persistent sudo Session: After using sudo once, your password is saved for 15 minutes by default.

Adding a User to sudo Group
If your user does not have sudo privileges, you must add them to the sudo group:
Add User: sudo usermod -aG sudo .
Verify: Log out and log back in for changes to take effect.

Important Notes
Root Password: By default, the root account is locked on Ubuntu, so you should use sudo instead of su.
Creating a new sudo user: Use sudo adduser followed by sudo usermod -aG sudo .

Files