Is there a keyboard key combination that I can use to pause a program running in the terminal? In case it matters, I don't intend to run anything else inside that terminal while the program is paused. I just want to pause the program execution, and resume it later. How can I do this?
Press Control+Z.
This will suspend the process and return you to a shell. You can do other things now if you want or you can return to the background process by entering
%
followed by Return.Note that if you're doing this to something that needs to be responsive, you're going to tank the system, but if it's just something like a
nano
instance, everything should be okay.This is bash job control
Use CTL-Z to stop the job.
Then you can type bg to run it in the background, if there's only on job it does exactly that.
If you have more than one you can use jobs to list then and use fg %N and bg %N to the desired effect.
Example:
For anything else not attached to the TTY you can use SIGSTOP and SIGCONT. So for example if you think a daemon is causing problems but you don't know which one it is, you can send the pid SIGSTOP, it's like hitting pause, then check for changes, OK that's not it, and rinse and repeat until you find the problem.
Hope this helps.
I know that this answer is a little bit late, but you can use the shortcut
Ctrl+s
to stop your programme (if you wanna may be read the output or something like this), then you can continue using the shortcutCtrl+q
.