How to exit sh program?

I bungled the commands and wrote sh -man

Now I’ve entered a program called sh-3.2 that is seemingly impossible to exit.

Ctrlc,Ctrlz, or Ctrlxdoes not work.

exit, quit, q, :q also does not work.

All google answers are for exiting shell scripts programmatically.

Asked By: The Unfun Cat


Try ctrl+d that should kill the shell.

Answered By: rhormaza

Ctrl+D does the trick for me.

Actually it is the -n flag that introduces this behaviour. It is meant to do only syntax checking of the commands, but doesn’t actually execute them.

Answered By: jippie

Try also typing ` which is in the same key as ~ on the keyboard, and then press Return. Ctrl+D kills the terminal but ` won’t.

Answered By: Jake

If you shell exit is pre planned then use,


Or you can program to handle SIGTERM and other signals
a sample tutorial

Or if you want to stop already running shell script


Or find the pid and kill it.

ps -ax | grep shell_name
pkill -9 PID_of_shell
Answered By: Nitesh Shetty

Hold Ctrl and press p q. This solved my issue.

Answered By: suryavamsi perla

I tried Ctrl + Alt + F2 then I returned to the desktop.
It worked!

Answered By: ASHKAN HMT
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.