screen命令基本用法

  1、screen:screen manager with VT100/ANSI terminal emulation

  1)简介:一个可以在多个进程(通常是交互式shell)之间复用一个物理终端的全屏幕窗口管理器

  使用screen时,程序“运行”在screen会话中(作为会话shell的子进程),此时detach会话不会中断会话中的程序。当再次attach该会话时,又可以回到detach之前的状态。

  2)常用选项:-S name:为会话指定名字;-r session:恢复detached的会话;-ls [match]:列举所有/匹配的会话;-d -m:以detached模式创建会话(常用于系统启动脚本);-d [match]:detach一个正在使用的会话。在会话控制终端键入Ctrl-a d可detach该会话;-wipe [match]:和-ls一样,但会移除已销毁的会话,而不是标记为dead。

  3)例子:

  (1)创建新会话:

screen -S han
vim test
# 若要终止会话:退出vim->键入Ctrl-d

screen vim test  # 直接指定在screen会话中运行的程序。这种情况下,退出vim即终止会话

  (2)在(1)中会话未终止时,键入Ctrl-a d,将detach该会话。

  (3)使用screen -ls查询所有会话:

[root@localhost ~]# screen -ls
There is a screen on:
        3985.han        (Detached)
1 Socket in /var/run/screen/S-root.

  可见会话当前状态是Detached的。

  (4)恢复会话:

screen -r 3985  # 回到detach前的状态

 

 

 

不断学习中。。。

posted on 2016-06-18 01:49  han'er  阅读(10260)  评论(0编辑  收藏  举报

导航