Linux下screen的简单介绍
2013-04-06 11:51 会被淹死的鱼 阅读(549) 评论(0) 编辑 收藏 举报screen是一个会话管理软件, 支持多个窗口, 每个窗口分别在独立的进程中, 方便日常工作的管理. 使用ssh登录到远程机器操作, 遇到长时间的操作, 很怕网络断开, 一旦断开之前的操作又要重来一遍, screen可以保存所有会话, 在断开后仍然可以重新登录连接, 本身的运行不会被终端, 多个窗口可以同时做多个事情, 并且可以随意切换, 非常方便的工具.
官网上的英文介绍:
Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. Each virtual terminal provides the functions of the DEC VT100 terminal and, in addition, several control functions from the ANSI X3.64 (ISO 6429) and ISO 2022 standards (e.g., insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move text regions between windows. When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the users terminal.
ubuntu下的安装命令
sudo apt-get install screen
screen常用命令
screen -S <name> 创建并打开一个叫name的screen会话, 打开的界面如下所示
screen -ls 查看当前有哪些screen会话在运行, 有Attached和Detached两个, ctrl+a+d就是保存会话退出, Detached状态, 之后可以恢复
screen -r <name> 连接到已有的screen会话, 例如使用screen -r test 重新连接到已有的会话中
配置文件参考文献2
#set coding #defencoding GBK #encoding UTF-8 GBK #see the startup message startup_message off term linux ##use ` as the Global Key ### escape `` ###set a biger buffer defscrollback 409600 ##设置状态栏 hardstatus alwayslastline shelltitle "$|bash" hardstatus string '%{= kG}[ %{G}%c:%s %{g}][%= %{= kw}%?%-Lw%?%{Y}%n*%f%t %{K}%?%+Lw%?%= %{kG}][ %{C}(F8)Screen (F9)Title (F10)Detach (F7)Prev (F12)Next %{kg}][%{kG} %l %Y/%m/%d %{kG}]' # a short version, can use C-a #hardstatus string '%{= kg}[ %{G}%c:%s %{g}][%= %{= kw}%?%-Lw%?%{Y}%n*%f%t %{K}%?%+Lw%?%= %{g}][%{kG} %D %Y/%m/%d %{g}]' # ###shutdown the noise vbell off # ### w to show the window list bind w windowlist -b bind ^w windowlist -b ###initial apps to run screen screen screen select 0 # ##进行快捷键的绑定 bindkey -k k8 screen bindkey -k k9 title bindkey -k k; detach bindkey -k k7 prev bindkey -k F2 next bindkey -k k4 quit attrcolor u "-u B" autodetach on
简单好用的screen, enjoy it!
参考文献:
- linux 技巧:使用 screen 管理你的远程会话: http://www.ibm.com/developerworks/cn/linux/l-cn-screen/
- 我的screen配置文件: http://blog.csdn.net/lonfee88/article/details/6607877