In Linux, which symbol or command is used to check the exit status of the last…

2025

In Linux, which symbol or command is used to check the exit status of the last executed command?

  1. A.

    $@

  2. B.

    $$

  3. C.

    $#

  4. D.

    $?

  5. E.

    echo $$

Attempted by 36 students.

Show answer & explanation

Correct answer: D

Answer: $?. In Bash/Linux shells, $? expands to the exit status of the most recently executed command. A value of 0 generally means success, while a non-zero value usually indicates failure or another command-specific condition. The other options refer to script arguments or shell process IDs, not the previous command status.

Explore the full course: Niacl Ao It Specialist