Linux作业管理(快捷键、命令)

Ctrl+C:结束当前命令

Ctrl+D:输入结束(EOF)

Ctrl+Z:当前作业放到后台并暂停

Ctrl+S:暂停屏幕输出

Ctrl+Q:恢复屏幕输出 

 

&:命令放在后台执行

jobs:查看后台作业

fg:作业后台到前台(后台stopped、后台running,到前台running)

bg:让作业后台运行(后台stopped,到后台running)

 

小实验

代码
$ ping localhost
#前台执行ping命令
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.049 ms
^Z
[
1]+ Stopped ping localhost

$ jobs
#查看后台作业
[
1]+ Stopped ping localhost

$ bg %1
#将ping从后台stopped,变为后台running
[
1]+ ping localhost &
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.098 ms

$ fg %1
#将ping从后台running,变为前台running
ping localhost
64 bytes from localhost (127.0.0.1): icmp_seq=10 ttl=64 time=0.039 ms
^Z
[
1]+ Stopped ping localhost
$

 

ps:后台运行的命令无法通过Ctrl+C或Ctrl+Z进行控制,需先转移到前台再控制;ubuntu的多个终端间无法看到对方的后台作业。

posted @ 2010-11-11 00:03  苏堤白堤杨公堤  阅读(1096)  评论(0编辑  收藏  举报