Lpic 1 Linux Administrator · Free Practice Question Easy

Question 16

What does the command echo $? output in a shell?
  • A The exit status of the most recently executed command
  • B The output of the previous echo command
  • C The process ID of the most recent background job
  • D The name of the current shell
Reveal correct answer

Correct answer: A

A. The command echo $? outputs the exit status of the most recently executed command in the shell. This is useful for checking whether a command was successful or not, as most commands return an exit status of 0 for success and non-zero for failure.

B. The command echo $? does not output the output of the previous echo command. It specifically retrieves and displays the exit status of the most recently executed command in the shell.

C. The command echo $? does not output the process ID of the most recent background job. It is solely used to display the exit status of the previous command executed in the shell.

D. The command echo $? does not output the name of the current shell. It is specifically used to display the exit status of the most recently executed command in the shell.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need