Mastering sudo: Temporary Privilege Escalation for LFCS Certification

Master sudo command for LFCS certification. Learn sudo vs su comparison, basic sudo usage, sudo -i, sudo -s, password caching, timeout settings, logging, and security best practices with comprehensive labs.

25 min read

Welcome to Part 4 of the LFCS Certification - Phase 1 series! In previous posts, you learned about the root user, groups, and the su command. Now it's time to master sudo - the modern, safer, and more flexible approach to privilege escalation in Linux.

๐Ÿ’ก

๐ŸŽฏ What You'll Learn: In this guide, you'll master:

  • What sudo is and why it's safer than su
  • Comprehensive sudo vs su comparison
  • Basic sudo command syntax and usage
  • sudo -i for interactive root shell
  • sudo -s vs sudo -i differences
  • The famous "sudo lecture" and what it means
  • Default admin users on RedHat vs Ubuntu
  • sudo password caching and timeout mechanism
  • How sudo logging provides accountability
  • sudo security features and benefits
  • 20+ comprehensive practice labs

Series: LFCS Certification Preparation - Phase 1 (Post 4 of 52) Previous: Part 3 - Understanding the Root User and su Command Next: Part 5 - Creating and Managing sudo Configuration (/etc/sudoers)

What is sudo?

sudo stands for "superuser do" or "substitute user do". It allows authorized users to run commands as another user (typically root) without needing to know that user's password.

The Philosophy Behind sudo

sudo embodies the principle of "least privilege":

Principle of Least Privilege with sudo
Regular User (UID 1000)
Default state: Minimal privileges
โ†“ Need admin task โ†“
sudo command
Temporary elevation for single command
โ†“ Command completes โ†“
Back to Regular User
Privileges automatically dropped

Key Characteristics of sudo

FeatureDescriptionBenefit
AuthenticationUses YOUR password, not root'sNo need to share root password
ScopeExecutes single commandAutomatic privilege drop
LoggingEvery sudo command is loggedFull audit trail of who did what
GranularityCan restrict specific commandsFine-grained access control
TimeoutCaches credentials temporarilyConvenient but secure

Why sudo is Safer Than su

Let's understand why sudo has become the preferred method for privilege escalation:

Security Advantages

1. No Root Password Sharing

# With su: Everyone needs root password
su -
Password: ******    # Root password shared with all admins

# With sudo: Use your own password
sudo command
[sudo] password for john: ******    # John's own password

2. Accountability

# With su: All actions appear as root
su -
useradd newuser    # Log shows: root created user
exit

# With sudo: Clear attribution
sudo useradd newuser    # Log shows: john ran useradd as root

3. Automatic Privilege Drop

# With su: Must remember to exit
su -
# ... doing admin work ...
# Oops, forgot to exit! Still root.

# With sudo: Privileges drop automatically
sudo command    # Runs as root
whoami          # Back to regular user automatically

4. Granular Control

# With su: All or nothing - full root access
su -    # Now can do ANYTHING

# With sudo: Can limit specific commands
# User can run only systemctl restart httpd
# Cannot run other admin commands

Comparison Table: sudo vs su

Aspectsudosu
Password RequiredYour own passwordTarget user's (root) password
Access TypeCommand-by-commandFull shell session
Privilege DurationSingle command (or cached 15 min)Until you explicitly exit
LoggingDetailed: who, what, whenBasic: who became root
GranularityCan limit to specific commandsAll or nothing
Root PasswordNot needed/sharedMust be shared
RevocationEasy (remove from sudoers)Hard (must change root password)
User TrackingExcellent (every command logged)Poor (all actions as root)
SecurityHigher (principle of least privilege)Lower (full root access)
Best ForMost tasks, production systemsExtended admin sessions, recovery
โœ…

โœ… For LFCS: Understand both sudo and su, but know that sudo is the modern best practice. The exam focuses on RedHat-based systems where sudo is the standard approach.

Basic sudo Usage

Let's learn the fundamental sudo command patterns.

Running a Single Command

Basic syntax:

sudo command [arguments]

Example: List root's home directory

# As regular user - fails
[centos9@centos ~]$ ls -l /root
ls: cannot open directory '/root': Permission denied

# With sudo - works!
[centos9@centos ~]$ sudo ls -l /root
[sudo] password for centos9: ******
total 16
-rw-------.   1 root root  999 Jul 20 15:35 anaconda-ks.cfg
drwxr-xr-x. 142 root root 8192 Oct 31 21:23 etc

What happened:

  1. sudo prompts for YOUR password (not root's)
  2. Checks if you're authorized (in wheel/sudo group)
  3. Runs the command as root
  4. Returns you to regular user after command completes

The Famous "sudo Lecture"

The first time you use sudo, you'll see this message:

[john@centos ~]$ sudo systemctl status sshd

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for john:

Why this message appears:

  • Reminds users of their responsibility
  • Only shown once per user
  • Can be disabled (but shouldn't be!)
  • A Unix tradition since sudo's creation

Common sudo Command Examples

1. Package installation:

# RedHat/CentOS
sudo dnf install nginx -y

# Ubuntu/Debian
sudo apt install nginx -y

2. Service management:

sudo systemctl restart sshd
sudo systemctl status httpd
sudo systemctl enable nginx

3. File editing:

sudo vi /etc/hosts
sudo nano /etc/hostname

4. User management:

sudo useradd newuser
sudo passwd newuser
sudo usermod -aG wheel newuser

5. Viewing logs:

sudo tail -f /var/log/messages
sudo cat /var/log/secure
sudo journalctl -xe

sudo Options: -i, -s, and More

sudo has several important options that change its behavior.

sudo -i: Interactive Login Shell

Usage:

sudo -i

What it does:

  • Starts an interactive login shell as root
  • Similar to su -
  • Loads root's environment completely
  • Changes to /root directory
  • Runs /etc/profile and ~/.bash_profile

Example:

[centos9@centos ~]$ whoami
centos9

[centos9@centos ~]$ sudo -i
[sudo] password for centos9:

[root@centos ~]# whoami
root

[root@centos ~]# pwd
/root

[root@centos ~]# echo $USER
root

[root@centos ~]# exit
logout

[centos9@centos ~]$ whoami
centos9

sudo -s: Non-Login Shell

Usage:

sudo -s

What it does:

  • Starts shell as root
  • Does NOT load login environment
  • Stays in current directory
  • Preserves environment variables

Example:

[centos9@centos ~]$ pwd
/home/centos9

[centos9@centos ~]$ sudo -s
[root@centos centos9]# whoami
root

[root@centos centos9]# pwd
/home/centos9    # Still in user's directory!

[root@centos centos9]# exit
exit

[centos9@centos ~]$

sudo -u: Run as Different User

Usage:

sudo -u username command

Example:

# Run command as user 'apache'
sudo -u apache touch /var/www/html/test.txt

# Run command as user 'postgres'
sudo -u postgres psql

sudo -l: List Allowed Commands

Usage:

sudo -l

Example output:

[centos9@centos ~]$ sudo -l
[sudo] password for centos9:
User centos9 may run the following commands on centos:
    (ALL) ALL

This shows what commands you're allowed to run with sudo.

Comparison: sudo -i vs sudo -s vs sudo su -

CommandShell TypeDirectoryEnvironment
sudo -iLogin shell/rootRoot's environment
sudo -sNon-login shellCurrent directoryCurrent environment
sudo su -Login shell/rootRoot's environment

Best practice:

  • Use sudo command for single commands
  • Use sudo -i if you need an interactive root shell
  • Avoid sudo -s (incomplete environment)
  • sudo su - works but sudo -i is cleaner

Default Admin Users: RedHat vs Ubuntu

Different distributions create different default administrative users during installation.

RedHat/CentOS/Fedora

During installation:

  • Creates user you specify (e.g., "centos9")
  • Automatically adds to wheel group
  • Can use sudo immediately

Check:

[centos9@centos ~]$ id
uid=1000(centos9) gid=1000(centos9) groups=1000(centos9),10(wheel)

[centos9@centos ~]$ sudo whoami
[sudo] password for centos9:
root

Ubuntu/Debian

During installation:

  • Creates user you specify (e.g., "ubuntu")
  • Automatically adds to sudo group
  • Can use sudo immediately

Check:

ubuntu@ubuntu:~$ id
uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),27(sudo)

ubuntu@ubuntu:~$ sudo whoami
[sudo] password for ubuntu:
root

Key Differences

AspectRedHat/CentOSUbuntu/Debian
Admin Groupwheelsudo
Group GID1027
Root AccountEnabled by defaultDisabled by default
su - rootWorks (if you know password)Doesn't work (no password set)
PhilosophyRoot available, prefer sudosudo only, no direct root access
๐Ÿ’ก

๐Ÿ’ก Ubuntu Root Account: On Ubuntu, the root account exists but has no password set. You can only become root via sudo -i or sudo su -. This forces the use of sudo for all administrative tasks.

sudo Password Caching and Timeout

One of sudo's convenient features is password caching.

How Password Caching Works

When you first use sudo:

[centos9@centos ~]$ sudo systemctl status sshd
[sudo] password for centos9: ******    # Prompted for password
# ... output ...

[centos9@centos ~]$ sudo systemctl status httpd
# ... output ...                         # No password prompt!

[centos9@centos ~]$ sudo ls -l /root
# ... output ...                         # Still no password prompt!

What's happening:

  • First sudo: Password required
  • Password cached for 15 minutes (default)
  • Subsequent sudo commands: No password needed
  • After 15 minutes: Password required again

The Timeout Mechanism

sudo Password Caching Timeline
T = 0 minutes
sudo command โ†’ Password required
T = 5 minutes
sudo command โ†’ No password (cached)
T = 10 minutes
sudo command โ†’ No password (cached)
T = 14 minutes
sudo command โ†’ No password (cached)
T = 16 minutes
sudo command โ†’ Password required again

Clearing the sudo Cache

Force sudo to forget your cached credentials:

sudo -k

Example:

[centos9@centos ~]$ sudo whoami
[sudo] password for centos9: ******
root

[centos9@centos ~]$ sudo whoami
root                          # No password needed

[centos9@centos ~]$ sudo -k   # Clear cache

[centos9@centos ~]$ sudo whoami
[sudo] password for centos9: ******    # Password required again
root

When to use sudo -k:

  • Before leaving your desk
  • In shared/public workstations
  • Security-conscious environments
  • Scripts that shouldn't rely on cached credentials

Validating sudo Credentials

Refresh your sudo timestamp without running a command:

sudo -v

Example:

[centos9@centos ~]$ sudo -v
[sudo] password for centos9: ******

[centos9@centos ~]$ sudo whoami
root                          # No password needed (just validated)

sudo Logging and Accountability

One of sudo's major security advantages is comprehensive logging.

Where sudo Logs Go

RedHat/CentOS:

sudo tail -f /var/log/secure

Ubuntu/Debian:

sudo tail -f /var/log/auth.log

Example sudo Log Entries

Nov  3 18:52:21 vm1 sudo: centos9 : TTY=pts/0 ; PWD=/home/centos9/LFCS ; USER=root ; COMMAND=/bin/ls -l /root
Nov  3 18:52:41 vm1 sudo: centos9 : TTY=pts/0 ; PWD=/home/centos9/LFCS ; USER=root ; COMMAND=/bin/bash -i
Nov  3 18:53:44 vm1 sudo: centos9 : TTY=pts/0 ; PWD=/home/centos9/LFCS ; USER=root ; COMMAND=/bin/su -

Breaking down a log entry:

Nov  3 18:52:21 vm1 sudo: centos9 : TTY=pts/0 ; PWD=/home/centos9/LFCS ; USER=root ; COMMAND=/bin/ls -l /root
โ”‚               โ”‚         โ”‚          โ”‚           โ”‚                        โ”‚           โ”‚
โ”‚               โ”‚         โ”‚          โ”‚           โ”‚                        โ”‚           โ””โ”€ Command executed
โ”‚               โ”‚         โ”‚          โ”‚           โ”‚                        โ””โ”€ Ran as this user (root)
โ”‚               โ”‚         โ”‚          โ”‚           โ””โ”€ From this directory
โ”‚               โ”‚         โ”‚          โ””โ”€ From this terminal
โ”‚               โ”‚         โ””โ”€ Username who ran sudo
โ”‚               โ””โ”€ Hostname
โ””โ”€ Timestamp

Viewing Recent sudo Activity

Show last 20 sudo commands:

sudo grep sudo /var/log/secure | tail -20

Show sudo commands by specific user:

sudo grep "sudo.*john" /var/log/secure

Show failed sudo attempts:

sudo grep "NOT allowed" /var/log/secure

Example failed attempt log:

Nov  3 19:24:03 vm1 sudo: labuser : user NOT in sudoers ; TTY=pts/0 ; PWD=/home/labuser ; USER=root ; COMMAND=/usr/sbin/useradd bob

This shows user labuser tried to run useradd but was denied because they're not in sudoers.

โœ…

โœ… For LFCS: Understanding sudo logs is crucial for troubleshooting access issues and security auditing. Know where logs are located on both RedHat and Debian systems.

๐Ÿงช Practice Labs

Time to master sudo with hands-on practice!

Lab 1: First sudo Command (Beginner)

  1. Check if you can use sudo:

    sudo -l
    
  2. Run a simple sudo command:

    sudo whoami
    # Should output: root
    
  3. Check your groups:

    id
    groups
    
  4. Verify you're in wheel (RedHat) or sudo (Ubuntu) group

  5. Try accessing root's home:

    ls -l /root          # Fails
    sudo ls -l /root     # Works!
    

Lab 2: sudo Password Caching (Beginner)

  1. First sudo command (requires password):

    sudo whoami
    # Enter password
    
  2. Immediate second command (no password):

    sudo ls /root
    # No password needed
    
  3. Wait 1 minute, try again:

    sleep 60
    sudo cat /etc/shadow
    # Still no password (within 15 min window)
    
  4. Clear sudo cache:

    sudo -k
    
  5. Try again (password required):

    sudo whoami
    # Password required again
    

Lab 3: Comparing sudo Options (Intermediate)

  1. Test sudo -i:

    pwd
    echo $USER
    sudo -i
    pwd           # Now in /root
    echo $USER    # Now root
    exit
    
  2. Test sudo -s:

    pwd
    sudo -s
    pwd           # Still in your directory
    echo $USER    # May still show your username
    exit
    
  3. Document the differences you observe

Lab 4: Package Installation with sudo (Intermediate)

  1. Try without sudo (fails):

    dnf install tree
    # Or: apt install tree
    # Should fail: Permission denied
    
  2. Try with sudo (works):

    sudo dnf install tree -y
    # Or: sudo apt install tree -y
    
  3. Verify installation:

    which tree
    tree --version
    

Lab 5: Service Management (Intermediate)

  1. Check service status (works without sudo):

    systemctl status sshd
    
  2. Try to restart without sudo (fails):

    systemctl restart sshd
    # Fails: Authentication required
    
  3. Restart with sudo (works):

    sudo systemctl restart sshd
    
  4. Check status again:

    systemctl status sshd
    

Lab 6: Viewing Logs with sudo (Intermediate)

  1. Try to view secure log without sudo:

    cat /var/log/secure
    # Or on Ubuntu: cat /var/log/auth.log
    # Should fail: Permission denied
    
  2. View with sudo:

    sudo tail -20 /var/log/secure
    # Or: sudo tail -20 /var/log/auth.log
    
  3. Follow logs in real-time:

    sudo tail -f /var/log/secure
    # Press Ctrl+C to stop
    
  4. Search for your sudo commands:

    sudo grep "sudo.*$(whoami)" /var/log/secure | tail -10
    

Lab 7: sudo as Different User (Advanced)

  1. Create test file as yourself:

    touch /tmp/myfile
    ls -l /tmp/myfile
    
  2. Create file as apache user:

    sudo -u apache touch /tmp/apachefile
    ls -l /tmp/apachefile
    # Owner: apache
    
  3. Run command as postgres (if installed):

    sudo -u postgres whoami
    # Output: postgres
    

Lab 8: sudo -l to Check Permissions (Advanced)

  1. List your sudo privileges:

    sudo -l
    
  2. Analyze the output:

    User centos9 may run the following commands on centos:
        (ALL) ALL
    
  3. Try as different user (if available):

    sudo -l -U testuser
    

Lab 9: Investigating sudo Logs (Advanced)

  1. Run several sudo commands:

    sudo whoami
    sudo ls /root
    sudo systemctl status sshd
    
  2. Check logs for your activity:

    sudo grep "sudo.*$(whoami)" /var/log/secure | tail -5
    
  3. Find all sudo usage today:

    sudo grep "$(date +%b\ %d)" /var/log/secure | grep sudo
    

Lab 10: Creating Admin User (Advanced)

  1. Create new user:

    sudo useradd -m adminuser
    sudo passwd adminuser
    
  2. Add to wheel/sudo group:

    # RedHat:
    sudo usermod -aG wheel adminuser
    
    # Ubuntu:
    sudo usermod -aG sudo adminuser
    
  3. Switch to new user and test:

    su - adminuser
    sudo whoami
    # Should work!
    exit
    

Lab 11-15: Real-World Scenarios

Lab 11: System Update via sudo

# RedHat
sudo dnf check-update
sudo dnf update -y

# Ubuntu
sudo apt update
sudo apt upgrade -y

Lab 12: File Editing

# Create backup first
sudo cp /etc/hosts /etc/hosts.backup

# Edit file
sudo vi /etc/hosts
# Or: sudo nano /etc/hosts

# Verify changes
sudo cat /etc/hosts

Lab 13: User Management Script

Create script using sudo:

#!/bin/bash
# manage-users.sh

echo "Creating users..."
sudo useradd user1
sudo useradd user2

echo "Setting passwords..."
echo "password123" | sudo passwd --stdin user1
echo "password123" | sudo passwd --stdin user2

echo "Adding to groups..."
sudo usermod -aG developers user1
sudo usermod -aG developers user2

echo "Done!"

Lab 14: Emergency System Check

# Check disk space
sudo df -h

# Check memory
sudo free -m

# Check top processes
sudo top -bn1 | head -20

# Check recent logins
sudo last | head -10

# Check failed login attempts
sudo grep "Failed password" /var/log/secure | tail -10

Lab 15: Network Configuration

# View network config
sudo ip addr show

# View routing table
sudo ip route show

# View firewall rules
sudo iptables -L -n -v

Lab 16-20: Advanced Challenges

Lab 16: Time how long sudo password cache lasts (use a loop)

Lab 17: Create a script that automatically clears sudo cache when done

Lab 18: Compare execution times: sudo command vs su -c "command"

Lab 19: Analyze sudo logs to find the most frequently used sudo commands

Lab 20: Create monitoring script to alert on failed sudo attempts

๐Ÿ“š Best Practices

โœ… sudo Best Practices

  1. Prefer sudo over su for most tasks

    • Better security through accountability
    • No need to share root password
    • Automatic privilege dropping
  2. Use specific commands, not sudo -i for everything

    # Good: Specific command
    sudo systemctl restart httpd
    
    # Acceptable: Multiple related tasks
    sudo -i
    # ... do several admin tasks ...
    exit
    
  3. Clear sudo cache when leaving workstation

    sudo -k
    
  4. Check what you're allowed to do

    sudo -l    # Know your permissions
    
  5. Read command carefully before sudo

    • Double-check paths
    • Verify command syntax
    • Consider consequences
  6. Don't use sudo for regular user tasks

    # Wrong
    sudo cp file.txt ~/documents/
    
    # Right (no sudo needed)
    cp file.txt ~/documents/
    
  7. Monitor sudo logs regularly

    sudo tail -50 /var/log/secure
    
  8. Use sudo -v to extend timeout without running commands

    sudo -v    # Refresh credentials
    
  9. Be cautious with sudo -i

    • Only use when needed for multiple commands
    • Exit immediately when done
    • Easy to forget you're root
  10. Educate users about sudo responsibility

    • The "sudo lecture" is there for a reason
    • With sudo access comes accountability
    • All commands are logged

๐Ÿšจ Common Pitfalls to Avoid

โš ๏ธ

โŒ Mistakes to Avoid

  1. Using sudo for non-admin tasks

    sudo mkdir ~/myfolder    # WRONG - don't need sudo
    mkdir ~/myfolder         # RIGHT
    
  2. Forgetting you're in sudo -i shell

    • Easy to run dangerous commands
    • Visual prompt should show # vs $
    • Set colored prompt for root
  3. Assuming sudo will always work

    • Check sudo -l first
    • Not all users have sudo access
    • May be limited to specific commands
  4. Not checking logs after problems

    • Logs show why sudo failed
    • Check /var/log/secure or /var/log/auth.log
    • Look for "NOT allowed" messages
  5. Relying too heavily on password caching

    • Creates complacency
    • 15-minute window is security risk if you walk away
    • Always sudo -k before leaving
  6. Using sudo in pipes incorrectly

    # Wrong - sudo doesn't apply to tee
    echo "text" > /etc/file    # Fails
    
    # Right - pipe through sudo tee
    echo "text" | sudo tee /etc/file
    
  7. Not understanding sudo -s vs sudo -i

    • sudo -s has incomplete environment
    • Prefer sudo -i for interactive shells
    • Or just use sudo command
  8. Sharing sudo passwords/credentials

    • Everyone should have their own account
    • Defeats accountability purpose
    • Revocation becomes impossible
  9. Not testing in safe environment first

    • sudo commands are powerful
    • Test in VM or dev system first
    • Production mistakes are costly
  10. Ignoring the sudo lecture message

    • It's not just decoration
    • Real reminder of responsibility
    • Think before you sudo

๐Ÿ“ Command Cheat Sheet

Basic sudo Commands

# Run command as root
sudo command

# Interactive root shell (login)
sudo -i

# Non-login shell
sudo -s

# Run as specific user
sudo -u username command

# List allowed commands
sudo -l

# Validate credentials
sudo -v

# Clear cached credentials
sudo -k

# Exit sudo shell
exit

Common sudo Patterns

# Package management (RedHat)
sudo dnf install package
sudo dnf update -y
sudo dnf remove package

# Package management (Ubuntu)
sudo apt update
sudo apt install package
sudo apt upgrade -y

# Service management
sudo systemctl start service
sudo systemctl stop service
sudo systemctl restart service
sudo systemctl status service
sudo systemctl enable service

# User management
sudo useradd username
sudo passwd username
sudo usermod -aG groupname username
sudo userdel username

# File operations
sudo cp file /etc/
sudo mv file /etc/
sudo rm /etc/file
sudo chmod 644 /etc/file
sudo chown root:root /etc/file

# Viewing protected files
sudo cat /etc/shadow
sudo less /var/log/secure
sudo tail -f /var/log/messages

# Editing system files
sudo vi /etc/hosts
sudo nano /etc/hostname

sudo Logging and Monitoring

# View sudo logs (RedHat)
sudo tail -f /var/log/secure
sudo grep sudo /var/log/secure

# View sudo logs (Ubuntu)
sudo tail -f /var/log/auth.log
sudo grep sudo /var/log/auth.log

# Show recent sudo activity
sudo grep sudo /var/log/secure | tail -20

# Show failed sudo attempts
sudo grep "NOT allowed" /var/log/secure

# Show sudo activity by user
sudo grep "sudo.*username" /var/log/secure

# Show sudo activity today
sudo grep "$(date +%b\ %d)" /var/log/secure | grep sudo

Checking sudo Access

# Am I in wheel/sudo group?
id | grep -E 'wheel|sudo'
groups | grep -E 'wheel|sudo'

# What can I run with sudo?
sudo -l

# Test sudo access
sudo whoami    # Should output: root

# Check other user's sudo access (requires root)
sudo -l -U username

๐ŸŽฏ Key Takeaways

โœ… Remember These Points

  1. sudo = safer than su - Uses your password, not root's
  2. Principle of least privilege - Only elevated for specific commands
  3. Everything is logged - Full accountability of who did what
  4. Password caching - 15-minute timeout (default) for convenience
  5. sudo -i for shell - Like su -, starts login shell as root
  6. sudo -s less useful - Non-login shell, incomplete environment
  7. wheel group (RedHat) - Members can use sudo
  8. sudo group (Ubuntu) - Members can use sudo
  9. sudo -k clears cache - Use before leaving workstation
  10. sudo -l shows permissions - Know what you're allowed to do
  11. Logs in /var/log/secure - RedHat/CentOS location
  12. Logs in /var/log/auth.log - Ubuntu/Debian location
  13. No root password needed - Major security advantage
  14. Granular control possible - Can limit specific commands
  15. Industry best practice - Modern standard for Linux administration

๐Ÿš€ What's Next?

Now that you've mastered the basics of sudo, you're ready to learn about sudo configuration and creating custom privilege policies!

In the next post (Part 5), we'll cover:

  • Understanding /etc/sudoers file structure
  • Using visudo safely (never edit sudoers directly!)
  • Basic sudoers syntax and rules
  • Granting specific commands to users
  • Restricting dangerous commands (like passwd root)
  • Creating command aliases
  • Setting sudo defaults (timeout, logging)
  • sudoers best practices
  • Comprehensive labs for custom sudo policies

Coming Up in Phase 1:

  • Part 6: Linux Command Basics (case sensitivity, options)
  • Part 7: Essential Navigation Commands (ls, pwd, cd, whoami)
  • Part 8: The touch Command and File Creation
  • And 44 more posts!

โœ…

๐ŸŽ‰ Congratulations! You've completed Part 4 of the LFCS Certification series. You now understand sudo, why it's safer than su, and how to use it effectively for privilege escalation.

Practice is essential! Complete the 20 practice labs to build confidence with sudo. Understanding sudo is fundamental to modern Linux system administration and is heavily tested in the LFCS exam.

Remember: sudo is not just a tool - it's a philosophy of security through accountability!

๐Ÿ’ฌ Discussion

I'd love to hear about your experience:

  • Do you prefer sudo or su for your daily admin work?
  • What's your most frequently used sudo command?
  • Have you ever been locked out due to sudoers misconfiguration?
  • How do you handle sudo in production environments?

Connect with me:

  • ๐Ÿ™ GitHub - LFCS practice scripts
  • ๐Ÿ“ง Contact - Questions about LFCS

This is Part 4 of 52 in the LFCS Certification - Phase 1 series. Stay tuned for Part 5: Creating and Managing sudo Configuration!

Owais

Written by Owais

I'm an AIOps Engineer with a passion for AI, Operating Systems, Cloud, and Securityโ€”sharing insights that matter in today's tech world.

I completed the UK's Eduqual Level 6 Diploma in AIOps from Al Nafi International College, a globally recognized program that's changing careers worldwide. This diploma is:

  • โœ… Available online in 17+ languages
  • โœ… Includes free student visa guidance for Master's programs in Computer Science fields across the UK, USA, Canada, and more
  • โœ… Comes with job placement support and a 90-day success plan once you land a role
  • โœ… Offers a 1-year internship experience letter while you studyโ€”all with no hidden costs

It's not just a diplomaโ€”it's a career accelerator.

๐Ÿ‘‰ Start your journey today with a 7-day free trial

Related Articles

Continue exploring with these handpicked articles that complement what you just read

More Reading

One more article you might find interesting