nerdexam
Linux_Foundation

LFCS · Question #91

Which of the following commands lists all defined variables and functions within Bash?

The correct answer is B. set. The set command in Bash is used to display all shell variables, environment variables, and shell functions within the current shell session.

Submitted by tom_us· Apr 18, 2026Essential Commands

Question

Which of the following commands lists all defined variables and functions within Bash?

Options

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

How the community answered

(14 responses)
  • B
    93% (13)
  • D
    7% (1)

Why each option

The `set` command in Bash is used to display all shell variables, environment variables, and shell functions within the current shell session.

Aenv

The `env` command primarily displays or sets environment variables, not all shell variables or functions.

BsetCorrect

The `set` command without any options outputs all shell variables, including local variables, environment variables, and shell functions, providing a comprehensive list of what's defined in the current shell session.

Cenv -a

The `env -a` option is not a standard or valid option for the `env` command to list all variables and functions; `env` focuses on environment variables.

Decho $ENV

`echo $ENV` would only print the value of the `ENV` environment variable, which usually points to a script to be sourced, not a list of all variables and functions.

Concept tested: Bash variable and function listing

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-set

Topics

#Bash commands#Shell variables#Shell functions#Environment variables

Community Discussion

No community discussion yet for this question.

Full LFCS Practice