Lab activity

sudo and Privilege Management

Learn how to configure and manage sudo privileges, delegate administrative access, and create secure sudo policies for Linux users and groups.

Overview

Privilege management is a critical Linux administration skill that allows administrators to grant users controlled access to administrative tasks without sharing the root account. In this lab, you will learn how to configure and manage sudo privileges for users and groups in a Linux environment. You will work with the sudo command, the /etc/sudoers file, and sudoers drop-in configurations located in /etc/sudoers.d/. You will also learn how to grant full or restricted administrative access, configure passwordless sudo, and validate sudo configurations safely.

In This Lab, You’ll Learn How To

  • View and understand sudo privileges
  • Grant sudo access to users and groups
  • Configure sudoers drop-in files
  • Create restricted sudo rules for specific commands
  • Configure passwordless sudo access
  • Validate sudo configurations using visudo
  • Run commands as other users using sudo

Key sudo Commands and Files

  • sudo for executing privileged commands
  • sudo -l for viewing sudo permissions
  • visudo for safely editing and validating sudoers files
  • /etc/sudoers for global sudo configuration
  • /etc/sudoers.d/ for custom sudo rules
  • usermod -aG for adding users to sudo-enabled groups

Command Examples

View available sudo privileges:

sudo -l

Add a user to the sudo group:

usermod -aG sudo username

Validate sudoers configuration:

visudo -c

Run a command as another user:

sudo -u username whoami

Create a sudoers rule:

echo 'user ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/user

Learning Outcomes

  • Understand Linux privilege delegation using sudo
  • Configure user and group-based sudo access
  • Create secure and maintainable sudo policies
  • Validate and troubleshoot sudo configurations
  • Develop practical Linux administration and security skills

Conclusion

Completing this lab will help you gain hands-on experience managing administrative privileges using sudo. You will learn how to safely delegate elevated access, enforce command restrictions, and manage sudo configurations using Linux best practices. These skills are essential for Linux system administration, LFCS preparation, and maintaining secure multi-user environments.