nerdexam
Linux_Foundation

LFCS · Question #837

You logged in as user tuxl, but now you want to switch users to tux2 with tux2's environment. How would you do this?

The correct answer is C. su - tux2. The su - tux2 command switches to the tux2 user by initiating a login shell, which ensures that tux2's full environment variables are loaded.

Submitted by devops_kid· Apr 18, 2026User and Group Management

Question

You logged in as user tuxl, but now you want to switch users to tux2 with tux2's environment. How would you do this?

Options

  • Asu tux2
  • Bsu-etux2
  • Csu - tux2
  • Dsu -m tux2
  • Esu-ftux2

How the community answered

(25 responses)
  • C
    92% (23)
  • D
    4% (1)
  • E
    4% (1)

Why each option

The `su - tux2` command switches to the `tux2` user by initiating a login shell, which ensures that `tux2`'s full environment variables are loaded.

Asu tux2

The `su tux2` command switches to the user `tux2` but retains the environment of the original user (`tux1`), which does not provide `tux2`'s environment.

Bsu-etux2

`su -e` is not a standard or correct option for establishing a new user's environment; `-e` (or `--preserve-environment`) typically preserves the *current* user's environment.

Csu - tux2Correct

The `su - tux2` command is the correct way to switch to user `tux2` and load their complete environment. The hyphen (`-`) after `su` simulates a full login, sourcing the target user's profile and setting up their home directory, PATH, and other environment variables appropriately.

Dsu -m tux2

The `su -m` (or `--preserve-environment`) option prevents `su` from setting up the target user's environment, keeping the original user's environment, which is not desired in this scenario.

Esu-ftux2

`su -f` (or `--fast`) passes the `-f` flag to the shell, which typically prevents it from sourcing startup files, thus not loading the target user's full environment.

Concept tested: Linux user switching and environment

Source: https://man7.org/linux/man-pages/man1/su.1.html

Topics

#User switching#su command#Shell environment

Community Discussion

No community discussion yet for this question.

Full LFCS Practice