Howto stop or terminate Linux command process with CTRL + C

Posted on in Categories , , , , , , , , , , last updated July 12, 2007

Q. Sometime I type command and accidentally hit the [ENTER] key and immeditly realized that it was wrong command. How do I stop process assuming that process is not going in background? For example
cp /path/* /wrong/path

Stop or terminate Linux command process with CTRL + C

A. To stop process hit CTRL + C, for example, you entered:
$ cp -r /path/* /wrong/path

To stop the command hit CTRL+C and retype the command:
$ cp -r /path/* /correct/path

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

3 comment

  1. Is there a way I can stop a command without actually switching focus to the terminal window running the command? More specifically I’m trying to stop a script that switches focus to other window. It’s a script running xdotool commands and sometimes it goes wrong and needs to be stopped quickly.

Leave a Comment