In this article, we cover the difference between the most used key shortcuts Ctrl + c and Ctrl + z. The text-based interface in Linux is quite useful in certain cases. A regular user may not use it much. But, if you are a System Administrator then it is tough to ignore it.
While working through a graphical interface, we can see the options through which we can either stop or cancel the job anytime. But, when it comes to text-based interfaces, we have to use certain key shortcuts to yield similar sort of outcomes.
The two useful key shortcuts that can help either cancel or stop the currently running process/job in the interface are Ctrl + c and Ctrl + z.
Difference between Ctrl + c and Ctrl + z
To effectively utilize these two key shortcuts, it is important to understand the difference between these two.
We start with Ctrl + c first. If some job is running in the foreground and it gets stuck. Then, we can just cancel it through Ctrl + c. It is worth mentioning here that, once a process is canceled through Ctrl + c, we can’t resume it later. Our work would start from the beginning in most cases. But, exceptions do exist.
On the other hand, if we use Ctrl + z in the same process. That means, we have stopped the process from functioning and it is sent to the background. Even if the process is stuck and we don’t see its progress. In those cases too, it would just stop that temporarily and send it to the background. From there, we can decide whether to bring it to the foreground or make it run in the background. Things would resume with Ctrl + z. But, the same can be said with Ctrl +c. We have covered more of it in detail in the article: Background and Foreground Processes in Ubuntu & How to Send a Process to Background in Linux.
So, once a process is canceled, it is gone. But, if we have stopped it then it can be resumed.
In conclusion, we have covered here the difference between Ctrl + c and Ctrl + z in Linux. Before using any of the two key shortcuts, we should understand how that would impact our work.