nerdexam
Linux_Foundation

LFCS · Question #273

To test a shell script called myscript, the environment variable FOOBAR must be removed temporarily. How can this be done?

The correct answer is C. env -u FOOBAR myscript. To temporarily remove an environment variable for a specific command, the env -u command is used to unset it only for that command's execution.

Submitted by marco_it· Apr 18, 2026Essential Commands

Question

To test a shell script called myscript, the environment variable FOOBAR must be removed temporarily. How can this be done?

Options

  • Aunset -v FOOBAR
  • Bset -a FOOBAR=""
  • Cenv -u FOOBAR myscript
  • Denv -i FOOBAR myscript

How the community answered

(52 responses)
  • A
    4% (2)
  • C
    94% (49)
  • D
    2% (1)

Why each option

To temporarily remove an environment variable for a specific command, the `env -u` command is used to unset it only for that command's execution.

Aunset -v FOOBAR

The `unset -v FOOBAR` command unsets the variable in the current shell, making the change permanent for the duration of that shell session, not just for `myscript`.

Bset -a FOOBAR=""

The `set -a FOOBAR=""` command exports `FOOBAR` as an empty string, meaning it still exists in the environment, rather than being removed.

Cenv -u FOOBAR myscriptCorrect

The `env` command can run a program in a modified environment. The `-u` option specifies a variable to unset in the environment for the command being executed, ensuring it's removed only for `myscript` and not in the current shell.

Denv -i FOOBAR myscript

The `env -i myscript` command executes `myscript` with an *empty* environment, meaning *all* current environment variables would be discarded, not just `FOOBAR`.

Concept tested: Environment variable manipulation with env

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

Topics

#Environment Variables#env command#Shell Scripting#Command Execution

Community Discussion

No community discussion yet for this question.

Full LFCS Practice