티스토리 툴바



2008/03/03 17:30

GNU screen

screen 사용 중에 기본적으로 알아두면 좋은 것들을 요약해보면 다음과 같다.

Useful command-line options

$ screen -r   ;  Reattach a session
$ screen -d -r; Reattach a session and if necessary detach it
                first.

$ screen -D -r; Reattach a session. If necessary  detach  and
                logout  remotely first

$ screen -list; list screen

Useful default key bindings (C-a means Ctrl-a)

C-a "       (windowlist -b)   Present  a list of all windows for selection.
C-a 0       (select 0)
...            ...
C-a 9       (select 9)
C-a -       (select -)    Switch to window number 0-9, or to the blank window.

C-a A       (title)       Allow the user to enter a name for  the  current window.

C-a c
C-a C-c     (screen)      Create  a  new window with a shell and switch to that window.

C-a d
C-a C-d     (detach)      Detach screen from this terminal.

C-a q
C-a C-q     (xon)         Send a control-q to the current window.

C-a space
C-a n
C-a C-n     (next)        Switch to the next window.


사용 예:

$ screen     ; screen 생성 (screen window 총 1개)

이제 screen 창에서 작업 가능

screen 사용 중 새로운 screen window를 현재 screen에 추가하려면

C-a c   Create a new window with a shell and switch to that window.

이제 screen window 총 2개. 현재 screen window list를 확인해보려면

C-a "       Present  a list of all windows for selection.

screen window를  전환하려면

C-a N          ; N 대신에 0~9를 누르면 창간 전환
또는
C-a space  또는 C-a n 또는 C-a C-n ; Switch to the next window.

screen window 구분을 쉽게 하기 위해서 title을 설정하려면

C-a A     ;Allow the user to enter a name for  the  current window.

이제 작업을 마쳐서 screen 창을 detach하려면

C-a d          ;Detach screen from this terminal.

이제 작업하던 screen window는 남아있으니 나중에 attach 해서 사용하면된다.

나중에 기존 사용하던 screen을 불러와서 사용하려면...

$ screen -d -r: Reattach a session and if necessary detach it first.
또는
$ screen -D -r: Reattach a session. If necessary  detach  and  logout  remotely first

이제 기존 screen windows들이 복구되어 작업을 계속할 수 있다.

FAQ:
1. 사용 중 screen window가 key input이 안 될때는

C-a q 또는 C-a C-q     ; Send a control-q to the current window.

가끔씩 key input이 꼬여 screen window에 key input이 안 될 때까 있는데 이 방법을 쓰면 대부분은 다시 정상으로 돌아온다.

2. screen을 사용할 때 hanterm 또는 xterm과 같은 터미널의 제목(title)이 자동으로 수정하도록 하려면?
예를 들어 home directory에 .screenrc파일에 다음을 추가하면 된다.

hardstatus string "[screen %n%?: %t%?] %h"

위의 예제는 screen number와 screen에서 지정한 title이 출력되도록 한 것이다.
예를 들어 screen에서 지정한 title이 "this is title"이라면,  터미널의 title bar에 "[screen 0: this is title]"과 같이 표시되며 screen 창을 바꾸면 바뀐 현재의 screen의 number와 title로 자동으로 바뀌게 된다.
%n, %?, %t와 같은 것의 의미는 screen man page의 "STRING ESCAPES" chapter를 참고하면 된다.

출처:
사용 경험
GNU screen manual: http://www.gnu.org/software/screen/manual/screen.html

저작자 표시 비영리 동일 조건 변경 허락
Trackback 0 Comment 0

Trackback : http://illuminati.tistory.com/trackback/10 관련글 쓰기