Linux命令中Ctrl+z、Ctrl+c和Ctrl+d的区别和使用
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 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
用户可以使用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 1 2 3 4 5 6 7 8 9 10 11
bg命令把被中断的任务放在后台执行.
例如:当你vi一个文件是,如果需要用shell执行别的操作,但是你又不打算关闭vi,因为你得存盘推出,你可以简单的按下Ctrl+z,shell会将vi进程挂起~,当你结束了那个shell操作之后,你可以用fg命令继续vi你的文件。
Ctrl+d 不是发送信号,而是表示一个特殊的二进制值,表示 EOF。
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20