A Linux administrator is logged in as a non-root user named sysadmin. The administrator's current working directory is /home/sysadmin. To perform a series of tasks that require elevated privileges and a clean root environment, the administrator executes the command sudo -i. Which of the following statements BEST describes the outcome of running this command?
The command starts a root shell but keeps the user in their current directory (/home/sysadmin) and preserves their original environment variables.
The command elevates privileges for the next single command the user types and then immediately returns them to their standard sysadmin shell.
The command starts a new login shell for the root user, changing the current directory to /root and loading the root user's environment.
The command prompts the user for the root password to start a new root shell, as it is an alias for the su - command.
The correct answer is that the command starts a new login shell for the root user, changing the directory and environment. The sudo -i (or --login) option simulates an initial login for the target user (root by default). This means it starts a login shell, which cleanses the environment of most variables from the previous user and executes the target user's login scripts (e.g., .profile, .bash_profile). As part of this process, the current working directory is changed to the target user's home directory, which is /root for the root user.
Running a root shell while remaining in the current directory and preserving the environment is more characteristic of the sudo -s command. Executing only a single command with elevated privileges is the default behavior of sudo when followed by a command (e.g., sudo apt update). The sudo -i command uses the current user's password for authentication, not the root user's password, which is a key feature of sudo itself.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the difference between `sudo -i` and `sudo -s`?
Open an interactive chat with Bash
Why does `sudo -i` use the current user's password instead of the root password?
Open an interactive chat with Bash
What scripts or configuration files are processed when `sudo -i` starts a login shell?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .