PEN-200 Linux Privilege Escalation Practice Question
Exhibit
uid=1001(user) gid=1001(user) groups=1001(user), 27(sudo)
$ sudo -l
Matching Defaults entries for user on debian:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User user may run the following commands on debian:
(ALL) NOPASSWD: /usr/bin/vimRefer to the exhibit. Given the sudo privileges, which command will successfully spawn a root shell?
⚠ Common exam trap
Candidates often try to execute vim normally or forget the critical syntax required to pass commands via flags, failing to utilize the built-in escape sequences needed to spawn a root shell.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
sudo /usr/bin/vim -c ':!/bin/sh'
The exhibit shows that the user can run 'vim' as root without a password. Since vim has a built-in shell execution feature, an attacker can escape the editor to a root-privileged command prompt. This is a classic example of misconfigured sudo rights, where allowing full access to a versatile utility that supports command execution effectively grants the user complete control over the system.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
sudo /usr/bin/vim -c ':!/bin/sh'
Why this is correct
The -c command flag executes a command immediately upon vim startup. By invoking :!/bin/sh, the user forces vim to spawn a system shell. Because vim is running with sudo privileges, the spawned shell inherits root permissions, effectively escalating the user's access level to the highest possible on the system.
- ✗
sudo /usr/bin/vim /etc/shadow
Why it's wrong here
Running vim on /etc/shadow allows you to view or edit the file, but it does not automatically spawn a shell. You would still need to execute a command from within vim to get a shell. Simply opening the file is not enough to gain persistent root access.
- ✗
sudo /usr/bin/vim --version
Why it's wrong here
The --version flag instructs vim to display its version information and then terminate. It does not provide an interactive editing environment or a way to escape to a shell. Therefore, this command is useless for the purpose of privilege escalation and will simply print information and exit immediately.
- ✗
sudo /usr/bin/vim -u NONE
Why it's wrong here
The -u NONE flag starts vim without loading any configuration files (vimrc). While this might be useful for troubleshooting, it does not provide a mechanism to escape to a shell. It keeps you within the vim editor interface, preventing you from executing system-level commands as the root user.
About these practice questions
This PEN-200 question is part of Courseiva's 285-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official OffSec exam blueprint
This PEN-200 practice question is part of Courseiva's free OffSec certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PEN-200 exam.