Ctrl+c,Ctrl+d,Ctrl+z在Linux中意义
Ctrl+c和ctrl+z都是中断命令,但是他们的作用却不一样.
Ctrl+c是强制中断程序的执行。
Ctrl+z的是将任务中断,但是此任务并没有结束,他仍然在进程中他只是维持挂起的状态。
[root@localhost ~]# ping baidu.com
PING 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 ms
64 bytes from 220.181.57.217: icmp_seq=2 ttl=128 time=76.6 ms
64 bytes from 220.181.57.217: icmp_seq=3 ttl=128 time=54.6 ms
64 bytes from 220.181.57.217: icmp_seq=4 ttl=128 time=72.7 ms
64 bytes from 220.181.57.217: icmp_seq=5 ttl=128 time=51.3 ms
64 bytes from 220.181.57.217: icmp_seq=6 ttl=128 time=124 ms
64 bytes from 220.181.57.217: icmp_seq=7 ttl=128 time=71.2 ms
64 bytes from 220.181.57.217: icmp_seq=8 ttl=128 time=52.4 ms
64 bytes from 220.181.57.217: icmp_seq=9 ttl=128 time=51.7 ms
64 bytes from 220.181.57.217: icmp_seq=10 ttl=128 time=254 ms
64 bytes from 220.181.57.217: icmp_seq=12 ttl=128 time=64.2 ms
64 bytes from 220.181.57.217: icmp_seq=13 ttl=128 time=51.8 ms
64 bytes from 220.181.57.217: icmp_seq=14 ttl=128 time=92.5 ms
64 bytes from 220.181.57.217: icmp_seq=15 ttl=128 time=52.1 ms
64 bytes from 220.181.57.217: icmp_seq=16 ttl=128 time=51.8 ms
^Z
[1]+ Stopped ping baidu.com
用户可以使用fg/bg操作继续前台或后台的任务,
fg命令重新启动前台被中断的任务,
[root@localhost ~]# fg
ping baidu.com
64 bytes from 180.149.132.47: icmp_seq=6 ttl=128 time=59.0 ms
64 bytes from 180.149.132.47: icmp_seq=7 ttl=128 time=67.2 ms
64 bytes from 180.149.132.47: icmp_seq=8 ttl=128 time=54.5 ms
64 bytes from 180.149.132.47: icmp_seq=10 ttl=128 time=55.9 ms
64 bytes from 180.149.132.47: icmp_seq=12 ttl=128 time=56.8 ms
64 bytes from 180.149.132.47: icmp_seq=13 ttl=128 time=60.0 ms
64 bytes from 180.149.132.47: icmp_seq=14 ttl=128 time=155 ms
^Z
[1]+ Stopped ping baidu.com
bg命令把被中断的任务放在后台执行.
例如:当你vi一个文件是,如果需要用shell执行别的操作,但是你又不打算关闭vi,因为你得存盘推出,你可以简单的按下Ctrl+z,shell会将vi进程挂起~,当你结束了那个shell操作之后,你可以用fg命令继续vi你的文件。
Ctrl+d 不是发送信号,而是表示一个特殊的二进制值,表示 EOF。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。