使用screen非常簡易.只需在SHELL鍵入screen,便可打開一個screen session。
而在每個screen session 下,所有命令都以 ctrl+a(C-a) 開始。
現在讓我來簡單介紹基本的命令
C-a c -> Create == 開啟新的 window
C-a n -> Next == 切換到下個 window
C-a p -> Previous == 前一個 window
C-a C-a -> Other == 在兩個 window 間切換
C-a w -> Windows == 列出已開啟的 windows 有那些
C-a 0 -> 切換到第 0 個 window
C-a 1..9 -> 切換到第 1..9 個window
C-a a -> 發出 C-a,在 emacs, ve, bash, tcsh 下可移到行首
C-a t -> Time,顯示當前時間,和系統的 load
C-a K(大寫) -> kill window,強行關閉當前的 window
C-a [ -> 進入 copy mode,在 copy mode 下可以回滾、搜索、複製就像用使用 vi 一樣
C-b Backward,PageUp
C-f Forward,PageDown
H(大寫) High,將游標移至左上角
L Low,將游標移至左下角
0 移到行首
$ 行末
w forward one word,以字為單位往前移
b backward one word,以字為單位往後移
Space 第一次按為標記區起點,第二次按為終點
Esc 結束 copy mode
C-a ] -> Paste,把剛剛在 copy mode 選定的內容貼上
C-a ? -> Help,顯示簡單說明
C-a d -> detach,將目前的 screen session (可能含有多個 windows)
丟到後臺執行當按了 C-a d 把 screen session detach 掉後,會回到還沒進 screen 時的狀態,此時在 screen session 裏每個 window 內運行的 process (無論是前臺/後臺)都在繼續執行,即使 logout 也不影響。下次 login 進來時:screen -ls -> 顯示所有的 screen sessions
screen -r [keyword] -> 選擇一個screen session 恢復對話若 screen -ls 裏有 Attached sessions:
screen -d [keyword] -> 強制 detach,以便「接手」過來
Key | Action | Notes |
---|---|---|
Ctrl+a c | new window | |
Ctrl+a n | next window | |
Ctrl+a p | previous window | |
Ctrl+a “ | select window from list | |
Ctrl+a Ctrl+a | previous window viewed | |
Ctrl+a S | split terminal horizontally into regions | Ctrl+a c to create new window there |
Ctrl+a | | split terminal vertically into regions | Requires debian/ubuntu patched screen 4.0 |
Ctrl+a :resize | resize region | |
Ctrl+a :fit | fit screen size to new terminal size | Ctrl+a F is the same. Do after resizing xterm |
Ctrl+a :remove | remove region | Ctrl+a X is the same |
Ctrl+a tab | Move to next region | |
Ctrl+a d | detach screen from terminal | Start screen with -r option to reattach |
Ctrl+a A | set window title | |
Ctrl+a x | lock session | Enter user password to unlock |
Ctrl+a [ | enter scrollback/copy mode | Enter to start and end copy region. Ctrl+a ] to leave this mod |
Ctrl+a ] | paste buffer | Supports pasting between windows |
Ctrl+a > | write paste buffer to file | useful for copying between screens |
Ctrl+a < | read paste buffer from file | useful for pasting between screens |
Ctrl+a ? | show key bindings/command names | Note unbound commands only in man page |
Ctrl+a : | goto screen command prompt | up shows last command entered |