Why do we use ctrl + c / ctrl + x / ctrl + z in terminal? [duplicate]

Because it's specified in POSIX, the IEEE norm for Unix-like computer systems.

Check Section 10.2 - Output Devices and Terminal Types of the POSIX.1 2008 (the latest) specification for all the shortcuts available.

To add up to your question, this is a brief explanation of what those shortcuts actually do.

When you press Ctrl-[letter], you are actually sending a signal to the process. A signal is a "flag" you provide to the process that gets interpretated and associated with an action.

  • Ctrl-C sends SIGINT, a signal that causes the process to terminate.

  • Ctrl-Z sends SIGTSTP, a signal this causes the process to suspend execution. In this case, it is resumable - try executing a command that will take a while and press Ctrl-Z; you'll see something in the lines of

    [1]+ Stopped [your command].

    Type fg in your Terminal and you'll see the process resuming, if it didn't end before resuming it.

  • Ctrl-X, in this case, is the shortcut nano uses to exit the process. Incidentally, there is a signal associated to Ctrl-x, but it's not related to nano.

TL;DR It's specified in POSIX.


+z and +c are shell signals.

ctrl+z is not killing the programm, it is sending it a signal (SIGTSTP) to suspend. Type fg to resume it. ctrl+c is another signal, this time the SIGINT to terminate. kbd+x is just a nano key binding.