Intermediate Linux & Shell Scripting
Q50 / 100

What is the difference between "su" and "su -" (or "su -l")?

Correct! Well done.

Incorrect.

The correct answer is A) "su" switches the user but retains the current shell's environment variables (like PATH and working directory), while "su -" (login shell) resets the environment to match a fresh login as the target user, including their home directory and profile scripts

A

Correct Answer

"su" switches the user but retains the current shell's environment variables (like PATH and working directory), while "su -" (login shell) resets the environment to match a fresh login as the target user, including their home directory and profile scripts

Explanation

"su -" simulates a full login as the target user, sourcing their shell profile files and switching to their home directory, while plain "su" keeps the calling user's environment, which can lead to unexpected PATH or directory issues.

Progress
50/100