14

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.

  • Title improvements welcome; I do not know if "sh program" is the correct term. – The Unfun Cat Nov 26 '12 at 7:46
  • 1
    Ctrl+D does the trick for me. – jippie Nov 26 '12 at 7:50
  • 1
    Post as answer so this thread can get an accepted answer. Will probably be useful to some other newb in the future. – The Unfun Cat Nov 26 '12 at 7:51
18

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.

1

Try ctrl+d that should kill the shell.

0

If you shell exit is pre planned then use,

exit

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

Or if you want to stop already running shell script

ctrl+c
ctrl+d
ctrl+z

Or find the pid and kill it.

ps -ax | grep shell_name
pkill -9 PID_of_shell
  • OP specifically stated that Ctrl-c,Ctrl-z, Ctrl-x and exit did not work. – Stephen Rauch Apr 7 '17 at 15:17
  • This doesn't work. – NelsonGon 11 hours ago
-1

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.

  • 1
    Typing what !? Remember that around the world different keys are in different places, so whatever is on your ~ key almost certainly won't reliably match someone else's. – roaima Nov 6 '15 at 17:51
  • @roaima they meant a backtick but the markup ate it. – terdon Nov 6 '15 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.