Learn all about exit command
exit - cause normal process termination or exit the shell
root:~# man exit
1.1 Check the Exit status of script
root@:~# cat temp.sh echo hello world exit -1 root@:~# bash temp.sh hello world root@:~# echo $? 255 root@:~#
2.1 Check the status of command
root@:~# ls temp.sh dns_name.txt mo_server.err script.txt root@:~# echo $? 0 root@:~#
3.1 Disconnect from the terminal and last executed command status
parth@:~# sudo su root@:~# echo hello there hello there root@:~# exit exit parth@:~# echo $? 0 parth@:~# sudo su root@:~# echo hello there hello there root@:~# exit 1 exit parth@:~# echo $? 1 parth@:~#