一天一命令-screen
阿新 • • 發佈:2017-06-18
screen 窗口管理器
一天一命令-screen
screen
多終端窗口管理器,可以通過該軟件同時連接多個本地或遠程會話,並自由切換
Use: screen [ -options ] [ cmd [ args ] ] screen -r [[pid.]tty[.host]] screen -r sessionowner/[[pid.]tty[.host]] -A 將所有的窗口都調整為目前終端機的大小 -c file 讀取指定配置文件 -d 剝離別處正在運行的會話 -D 剝離並退出遠程會話 -h 設置回滾的命令歷史大小 -l 記錄登錄狀態(記錄到/var/run/utmp),-ln 關閉 -ls 顯示所有的會話連接 -L 開啟輸出日誌記錄 -m 忽略當前進程變量,建立新的會話 -r [session] 重回剝離的會話 -R 重回剝離的會話,如果找不到則創建新的會話 -s shell 指定建立新會話的shell -S name 創建會話並指定名稱 -t title 設置標題 -wipe [match] 清除無法使用的會話 -x 恢復之前的會話
分清終端,會話,窗口的概念
終端:遠程開啟一個ssh連接,表示開啟一個登錄終端
會話:開啟一個screen會話,如screen -S help表示開啟一個會話help
窗口:進入screen會話,可以建立多個窗口,如通過快捷鍵C-a S可以分割窗口
screen -S help //新建一個會話help screen -ls //列出所有的會話 screen -r num //重新連接指定num或者name的會話,之前的操作依然還在 screen -r help //回到會話help screen -d help //剝離會話help screen -d -r help2 //結束當前會話回到指定會話 exit //退出screen會話,提示信息screen is terminating
screen會話中的快捷鍵,以下快捷鍵都是以Ctrl+a開始的,以下均省略,不再說明
Ctrl+a ? 顯示所有快捷鍵
c 創建新的shell窗口並切換,exit關閉或退出
A 重命名當前窗口,輸入新名稱,然後回車
d 剝離會話,暫時斷開當前會話
k 中斷當前會話,關閉窗口及窗口中正在運行的進程,同exit
n 切換到下一個窗口
p 切換到上一個窗口
0-9 切換到0-9指定窗口
w 列出當前所有窗口,*號表示當前窗口
如果需要較長時間的操作,可以通過screen命令來避免斷網導致命令執行中斷:
screen
yes
斷開連接,重新連接
screen -ls
screen -r
命令繼續執行
exit //命令執行完畢後退出screen窗口
screen遠程幫助:
兩個終端都通過ssh連接到同一主機
screen -S help //在終端1創建會話help
screen -x help //在終端2加入會話help,可以同時加入多個終端,並且命令都是即時顯示的
exit //當有一個終端退出,則screen所有會話都會退出
man screen中的快捷鍵定義:
The following table shows the default key bindings: C-a ? (help) 查看快捷鍵列表 C-a ‘ (select) 輸入num或name,直接跳轉到指定num或name的會話 C-a " (windowlist -b) 顯示所有會話列表,方向鍵選擇,回車進入 C-a 0-9 (select 0-9) 選擇指定會話,可以先通過C-a w顯示所有會話 C-a tab (focus) 切換到下一個會話 C-a C-a (other) 在當前會話和上一次會話之間跳轉 C-a a (meta) Send the command character (C-a) to window. See escape command. C-a A (title) 設置當前窗口的名稱name C-a b (break) Send a break to window. C-a B (pow_break) Reopen the terminal line and send a break. C-a c (screen) 創建一個新窗口並跳轉到新窗口 C-a C (clear) 清空當前窗口的內容,類似於clear C-a d (detach) 剝離當前會話 C-a D D (pow_detach) 剝離並且退出當前終端logout C-a f (flow) Toggle flow on, off or auto. C-a F (fit) Resize the window to the current region size. C-a C-g (vbell) Toggles screen‘s visual bell mode. C-a h (hardcopy) Write a hardcopy of the current window to the file "hardcopy.n". C-a H (log) 開始/結束記錄當前窗口內容到文件screenlog.n(n表示為num) C-a i (info) 顯示當前窗口的信息 C-a k (kill) 關閉當前窗口 C-a l (redisplay) Fully refresh current window. C-a L (login) Toggle this windows login slot. Available only if screen is configured to update the utmp database. C-a m (lastmsg) Repeat the last message displayed in the message line. C-a M (monitor) Toggles monitoring of the current window. C-a n (next) 跳轉到下一個窗口 C-a N (number) 顯示當前窗口的num和名稱name C-a p (prev) 跳轉到上一個窗口 C-a q (xon) Send a control-q to the current window. C-a Q (only) Delete all regions but the current one. See also split, remove,focus. C-a r (wrap) Toggle the current window‘s line-wrap setting (turn the current window‘s automatic margins on and off). C-a s (xoff) Send a control-s to the current window. C-a S (split) 水平分割當前窗口 C-a t (time) 顯示系統時間和負載 C-a v (version) Display the version and compilation date. C-a C-v (digraph) Enter digraph. C-a w (windows) 顯示當前所有開啟的窗口,*號表示當前窗口 C-a W (width) Toggle 80/132 columns. C-a x (lockscreen) 鎖定終端,解鎖需要密碼 C-a X (remove) Kill the current region. See also split, only, focus. C-a z (suspend) Suspend screen. Your system must support BSD-style job-control. C-a Z (reset) Reset the virtual terminal to its "power-on" values. C-a . (dumptermcap) Write out a ".termcap" file. C-a C-\ (quit) Kill all windows and terminate screen. C-a : (colon) Enter command line mode. C-a [或者esc (copy) Enter copy/scrollback mode. C-a ] (paste .) Write the contents of the paste buffer to the stdin queue of the current window. C-a {或者} (history) Copy and paste a previous (command) line. C-a > (writebuf) Write paste buffer to a file. C-a < (readbuf) Reads the screen-exchange file into the paste buffer. C-a = (removebuf) Removes the file used by C-a < and C-a >. C-a , (license) Shows where screen comes from, where it went to and why you can use it. C-a _ (silence) Start/stop monitoring the current window for inactivity. C-a | (split -v) Split the current region vertically into two new ones. C-a * (displays) Show a listing of all currently attached displays.
本文出自 “rackie” 博客,請務必保留此出處http://rackie386.blog.51cto.com/11279229/1939442
一天一命令-screen