0
0
Linux CLIscripting~20 mins

sudo for elevated privileges in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sudo Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this sudo command?
You run the command sudo -l as a normal user. What does this command show?
Linux CLI
sudo -l
ALists the commands the user can run with sudo, possibly without a password
BShows the current user's password
CDisplays the system's uptime
DStarts a root shell immediately
Attempts:
2 left
💡 Hint
Think about what 'sudo -l' is used for in daily tasks.
💻 Command Output
intermediate
2:00remaining
What happens when you run this sudo command?
What is the output or effect of running sudo echo 'Hello' in a terminal?
Linux CLI
sudo echo 'Hello'
APrints 'Hello' to the terminal
BPrints an error about permission denied
CRuns echo as root but prints 'Hello' as the normal user
DDoes nothing and returns to prompt silently
Attempts:
2 left
💡 Hint
Consider how sudo affects simple commands like echo.
🔧 Debug
advanced
2:00remaining
Why does this sudo command fail?
You try to run sudo cat /etc/shadow but get a 'Permission denied' error. What is the most likely reason?
Linux CLI
sudo cat /etc/shadow
AThe cat command is not installed on the system
BThe /etc/shadow file does not exist
CYou need to use 'su' instead of 'sudo' to read this file
DYour user is not in the sudoers file and cannot run sudo commands
Attempts:
2 left
💡 Hint
Think about user permissions and sudo access.
🧠 Conceptual
advanced
2:00remaining
What does the sudoers file control?
Which of the following best describes the purpose of the sudoers file?
AIt stores encrypted passwords for all users
BIt defines which users can run which commands with sudo privileges
CIt logs all sudo command executions
DIt contains system-wide environment variables
Attempts:
2 left
💡 Hint
Think about how sudo controls access.
🚀 Application
expert
2:00remaining
How to run a command as another user with sudo?
You want to run the command whoami as the user 'alice' using sudo. Which command will do this correctly?
Asudo --user=whoami alice
Bsudo whoami -u alice
Csudo -u alice whoami
Dsudo alice whoami
Attempts:
2 left
💡 Hint
Look for the correct sudo option to specify a different user.