Ctrl+c,Ctrl+d,Ctrl+z在Linux中意義
Ctrl+c和ctrl+z都是中斷命令,但是他們的作用卻不一樣.
Ctrl+c是強制中斷程序的執(zhí)行。
Ctrl+z的是將任務中斷,但是此任務并沒有結束,他仍然在進程中他只是維持掛起的狀態(tài)。
[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操作繼續(xù)前臺或后臺的任務,
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命令把被中斷的任務放在后臺執(zhí)行.
例如:當你vi一個文件是,如果需要用shell執(zhí)行別的操作,但是你又不打算關閉vi,因為你得存盤推出,你可以簡單的按下Ctrl+z,shell會將vi進程掛起~,當你結束了那個shell操作之后,你可以用fg命令繼續(xù)vi你的文件。
Ctrl+d 不是發(fā)送信號,而是表示一個特殊的二進制值,表示 EOF。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。