Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report