Get the App
SLTechnology News&Howtos  ›  Servers  › 

Detailed explanation of the difference and use of Ctrl+z, Ctrl+c and Ctrl+d in Linux command

Shulou Source: shulou.com Published: 2022-06-02 01:45:21 09月23日 Update

The meaning of Ctrl+c,Ctrl+d,Ctrl+z in Linux

Both Ctrl+c and ctrl+z are interrupt commands, but their functions are not the same.

Ctrl+c is forced to interrupt the execution of the program.

Ctrl+z is to interrupt the task, but the task is not over, he is still in the process, he just maintains a suspended state.

[root@localhost] # ping baidu.comPING baidu.com (220.181.57.217) 56 (84) bytes of data.64 bytes from 220.181.57.217: icmp_seq=1 ttl=128 time=58.7 ms64 bytes from 220.181.57.217: icmp_seq=2 ttl=128 time=76.6 ms64 bytes from 220.181.57.217: icmp_seq=3 ttl=128 time=54.6 ms64 bytes from 220.181.57.217: icmp_seq=4 ttl=128 time=72.7 ms64 bytes from 220.181.57.217: icmp_seq=5 ttl=128 time=51. 3 ms64 bytes from 220.181.57.217: icmp_seq=6 ttl=128 time=124 ms64 bytes from 220.181.57.217: icmp_seq=7 ttl=128 time=71.2 ms64 bytes from 220.181.57.217: icmp_seq=8 ttl=128 time=52.4 ms64 bytes from 220.181.57.217: icmp_seq=9 ttl=128 time=51.7 ms64 bytes from 220.181.57.217: icmp_seq=10 ttl=128 time=254 ms64 bytes from 220.181.57.217: icmp_seq=12 ttl=128 time=64.2 ms64 bytes from 220.181.57.217: icmp_seq=13 ttl=128 Time=51.8 ms64 bytes from 220.181.57.217: icmp_seq=14 ttl=128 time=92.5 ms64 bytes from 220.181.57.217: icmp_seq=15 ttl=128 time=52.1 ms64 bytes from 220.181.57.217: icmp_seq=16 ttl=128 time=51.8 Ms ^ Z [1] + Stopped ping baidu.com

Users can use fg/bg operation to continue tasks in the foreground or background.

The fg command restarts the task interrupted by the foreground

[root@localhost] # fgping baidu.com64 bytes from 180.149.132.47: icmp_seq=6 ttl=128 time=59.0 ms64 bytes from 180.149.132.47: icmp_seq=7 ttl=128 time=67.2 ms64 bytes from 180.149.132.47: icmp_seq=8 ttl=128 time=54.5 ms64 bytes from 180.149.132.47: icmp_seq=10 ttl=128 time=55.9 ms64 bytes from 180.149.132.47: icmp_seq=12 ttl=128 time=56.8 ms64 bytes from 180.149.132.47: icmp_seq=13 ttl=128 time=60.0 ms64 bytes From 180.149.132.47: icmp_seq=14 ttl=128 time=155 Ms ^ Z [1] + Stopped ping baidu.com

The bg command leaves interrupted tasks executed in the background.

For example: when you vi a file, if you need to use shell to perform other operations, but you do not intend to close vi, because you have to save the disk to launch, you can simply press Ctrl+z,shell to suspend the vi process. When you finish that shell operation, you can use the fg command to continue to vi your files.

Instead of sending a signal, Ctrl+d represents a special binary value, which represents EOF.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Tags: Tasks commands foreground background files processes special binary functions signals content just that is meaning status users programs but learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi Shulou Tech Info NVidia MySQL