nerdexam
Linux_Foundation

LFCS · Question #443

Which of the following is the BEST way to list all defined shell variables?

The correct answer is B. set. The set command without any arguments is the most effective tool to display all shell variables, including environment variables, local variables, and shell functions.

Submitted by tom_us· Apr 18, 2026Essential Commands

Question

Which of the following is the BEST way to list all defined shell variables?

Options

  • Aenv
  • Bset
  • Cenv -a
  • Decho $ENV

How the community answered

(38 responses)
  • A
    5% (2)
  • B
    89% (34)
  • C
    3% (1)
  • D
    3% (1)

Why each option

The `set` command without any arguments is the most effective tool to display all shell variables, including environment variables, local variables, and shell functions.

Aenv

`env` displays only environment variables, not local shell variables or shell functions.

BsetCorrect

The `set` command, when executed without any arguments, displays all defined shell variables, including local variables set within the current shell, environment variables inherited or exported, and shell functions.

Cenv -a

`env -a` is not a standard or valid option for the `env` command in most shell implementations.

Decho $ENV

`echo $ENV` will only display the value of a specific variable named `ENV`, which is not a standard mechanism for listing all shell variables.

Concept tested: Listing shell variables

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

Topics

#shell variables#environment variables#set command#bash basics

Community Discussion

No community discussion yet for this question.

Full LFCS Practice