nerdexam
Linux_Foundation

LFCS · Question #2

When the command echo $$ outputs 12942, what is the meaning of 12942?

The correct answer is B. It is the process ID of the current shell. The special shell variable $$ expands to the process ID (PID) of the shell instance that is currently executing the command.

Submitted by devops_kid· Apr 18, 2026Essential Commands

Question

When the command echo $$ outputs 12942, what is the meaning of 12942?

Options

  • AIt is the process ID of the echo command.
  • BIt is the process ID of the current shell.
  • CIt is the process ID of the last command executed.
  • DIt is the process ID of the last command which has been placed in the background.

How the community answered

(20 responses)
  • B
    95% (19)
  • C
    5% (1)

Why each option

The special shell variable `$$` expands to the process ID (PID) of the shell instance that is currently executing the command.

AIt is the process ID of the echo command.

The `$$` variable does not represent the process ID of the `echo` command itself; `echo` runs as a child process and would have a different PID.

BIt is the process ID of the current shell.Correct

The `$$` special parameter in shell scripting is used to retrieve the process ID of the current shell or subshell in which the command is running. Thus, `echo $$` displays the PID of your interactive shell session.

CIt is the process ID of the last command executed.

The `$$` variable specifically refers to the current shell's PID, not the PID of the last command executed, which would typically be a different value.

DIt is the process ID of the last command which has been placed in the background.

The `$$` variable refers to the current shell's PID, while the PID of the last command placed in the background is stored in the `$!` variable.

Concept tested: Shell special variable `$$` (current shell PID)

Source: https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters

Topics

#Shell variables#Process ID (PID)#Bash shell#Command line basics

Community Discussion

No community discussion yet for this question.

Full LFCS Practice