EXIT STATUS in Linux / Ubuntu System

1.1 'EXIT STATUS' in linux / Ubuntu systems​

EXIT STATUS in the linux system means whether the command was successfully executed or executed with error. EXIT STATUS is an integer number value. Non zero (1-255) shows the error status of the command executed. while the 0 shows the command is successfully executed.

You can check whether the command was executed successfully using the following command ‘echo $?’, it will display the exit status code either 0 or non zero

$ echo $?

It will show you the exit code of the command executed previously. ‘$?’ is actually a shell variable and it shows the result of the previously executed command.

From the below outputs which can see that the ‘echo hello’ command was executed successfully and status can be checked using ‘echo $?’ and it gives ‘0′ as exit status. 

and Further, the exit code of the command ‘amul’ is 127 which is non-zero as the non existantence of the command and is giving error.

That’s all for the EXIT STATUS !!  Hope you enjoyed if you find any difficulty, you can write in the below comment section and I’ll get back to you. See you in the next article

Leave a Reply