Back to course

49. Utilizing `sudo` for Elevated Privileges

Linux Basics: From Zero to CLI Hero

Administrative Power Without Root Login

Logging in directly as the root user is generally discouraged due to the risk of accidentally running catastrophic commands. Instead, modern Linux distributions use sudo (SuperUser DO) to allow authorized users to execute specific commands as root.

How sudo Works

sudo precedes the command you want to run with elevated privileges.

bash

Install a new package (requires root access)

$ sudo apt install htop

Check the contents of the root user's home directory

$ sudo ls -la /root

When you run sudo for the first time in a session, it asks for your user password, not the root password, demonstrating that the system trusts you to run that command.

sudo Configuration

Users who can use sudo are typically members of the sudo or wheel group. Their permissions are configured in the secured configuration file: /etc/sudoers.