-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux sudo Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to sudo on Linux, covering Arch Linux, CachyOS, and other distributions including sudo configuration, user permissions, and security settings.
sudo allows users to run commands as another user (usually root).
Benefits:
- Security: No need for root password
- Audit trail: Logs all sudo commands
- Granular control: Fine-grained permissions
- Safety: Prevents accidental damage
Why use sudo:
- Best practice: Safer than su
- Accountability: Track who did what
- Flexibility: Configure per-user permissions
Arch/CachyOS:
# Install sudo
sudo pacman -S sudo
# Usually pre-installedDebian/Ubuntu:
sudo apt install sudoFedora:
sudo dnf install sudoCheck sudo:
# Check version
sudo --version
# Check if user in sudoers
sudo -lBasic usage:
# Run command as root
sudo command
# Example
sudo pacman -S package-nameBecome root:
# Switch to root shell
sudo su
# Or
sudo -iDifferent user:
# Run as specific user
sudo -u username command
# Example
sudo -u www-data ls /var/wwwConfigure sudo:
# Edit sudoers (safe)
sudo visudo
# Never edit directly with regular editorAllow user sudo:
# In visudo
username ALL=(ALL) ALL
# Or group
%wheel ALL=(ALL) ALLGranular permissions:
# Allow specific command
username ALL=(ALL) /usr/bin/pacman
# No password
username ALL=(ALL) NOPASSWD: ALL
# Specific host
username hostname=(ALL) ALLCheck configuration:
# Check sudo access
sudo -l
# Verify user in wheel group
groups
# Add to wheel group
sudo usermod -aG wheel usernameCheck logs:
# Check sudo logs
sudo journalctl -u sudo
# Or
cat /var/log/auth.logThis guide covered sudo installation, configuration, and usage for Arch Linux, CachyOS, and other distributions.
- User and Groups - User management
- Security Configuration - Security setup
- PAM Guide - Authentication
-
sudo Documentation:
man sudo
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.