screen 사용법

http://sulac.egloos.com/5623987

Vi와 같이 쓰기 좋은 Screen..
매번 Vi로 열고 이동하기 힘들었는데.. 좋다.. 흐흐흐... 

시작. : screen -S 세션명

Ctrl+a A :현재 screen의 이름을 정한다. (나중에 Ctrl+a w 나 Ctrl+a "로 볼때 이름이 다 똑같아서 정의해 놓는게 정신건강에 좋다)
Ctrl+a c : screen에서 새창 띄우기
Ctrl+a k : 현재 screen 죽이기.


Ctrl+a a : 바로 전 창으로
Ctrl+a n : 다음 창으로 
Ctrl+a p: 이전 창으로 

Ctrl+a " : 열린 screen list 을 보여줌.

Ctrl+a 0 : 0번째 창으로
Ctrl+a 1 : 1번째 창으로
Ctrl+a 9 : 10번째 창으로

Ctrl+a d : screen 때어내기 (현재 상태로 남겨두는거..)
Ctrl+a x : 이전에 남겨둔 screen에 다시 붙이기.
screen -r 세션명 : 강제로 종료된거에 다시 붙이기

ps -eaf | grep screen : 여러개 열려있을 경우 찾아서 죽여주는 센스.

screen -list : 현재 열려있는 리스트를 보여줌.

Ctrl+a ?  : 도움말
Ctrl+a k  : 스크린 닫기
Ctrl+a ESC, Ctrl+a [   : 화면 스크롤
Ctrl+a ] : 붙여넣기.

Ctrl+a S          화면 수평 분할
Ctrl+a |            화면 수직 분할
Ctrl + a :resize   resize region 
Ctrl + a :fit         fit screen size to new terminal size
Ctrl +a :remove  remove region
Ctrl+a Q           현재 region을 제외한 나머지 숨기기
Ctrl+ a tab      화면 분할 이동
Ctrl+a, :            명령행 모드로 전환

Ctrl+ X        : 현재 화면 닫기

마지막 종료는 exit로 하면 깔끔하게 나온다고 함. 

screen을 사용할때 마우스 휠로 올리거나 내리는게 안되는데... 이걸 해결하는 방법을 찾았다.
~/.screenrc에 아래 두줄을 추가하면.. 된다.. (문제는 창을 두개로 띄웠을때는 안되네 ㅡ.ㅡ)
defscrollback 5000
termcapinfo xterm* ti@:te@

추가적으로... 그냥 키보드로 정보를 보고 싶으면....
Ctrl+a, [ 누른후 화살표로 움직이면 된다. ^^;

screen으로 화면을 분할해서 사용할때 다음 창으로 가는게 ctrl+a - tab 만 있는줄 알았으나.. 입맛대로 수정하면 되네..
아래처럼 각 키를 넣어서 사용할수 있다.. ㅋㅋㅋ
$ vi .screenrc 
bind j focus down
bind k focus up
bind t focus top
bind b focus bottom



더 보시고 싶은 분들은 /usr/doc/screen 나 man을 활용하시기 바랍니다.

screen -h
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-list         or -ls. Do nothing, just list our SockDir.
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r            Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.00.03jw4 (FAU) 2-May-06".
-wipe         Do nothing, just clean up SockDir.
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

                                 Screen key bindings, page 1 of 1.

                                 Command key:  ^A   Literal ^A:  a

 break       ^B b        history     { }         other       ^A          split       S
 clear       C           info        i           pow_break   B           suspend     ^Z z
 colon       :           kill        K k         pow_detach  D           time        ^T t
 copy        ^[ [        lastmsg     ^M m        prev        ^H ^P p ^?  title       A
 detach      ^D d        license     ,           quit        \           vbell       ^G
 digraph     ^V          lockscreen  ^X x        readbuf     <           version     v
 displays    *           log         H           redisplay   ^L l        width       W
 dumptermcap .           login       L           remove      X           windows     ^W w
 fit         F           meta        a           removebuf   =           wrap        ^R r
 flow        ^F f        monitor     M           reset       Z           writebuf    >
 focus       ^I          next        ^@ ^N sp n  screen      ^C c        xoff        ^S s
 hardcopy    h           number      N           select      '           xon         ^Q q
 help        ?           only        Q           silence     _

^]   paste .
"    windowlist -b
-    select -
0    select 0
1    select 1
2    select 2
3    select 3
4    select 4
5    select 5
6    select 6
7    select 7
8    select 8
9    select 9
I    login on
O    login off
]    paste .
|    split -v
:kB: focus up

가끔 screen이 먹통이 될때.. 아래의 방법을 사용하면 된다.
요약하면
screen -ls로 리스트 보고
screen -r name 쳐서 붙이고
Ctrl+a 누르고 :quit 치면...
screen이 죽는다.. 라는거다.. 
 
  1. type "screen -list" to identify the (detached) screen session. eg: screen -list There are screens on: 20751.Melvin_Peter_V42 (Detached) Note: "20751.Melvin_Peter_V42" is your session id.

  2. get attached to the detached screen session eg: screen -r 20751.Melvin_Peter_V42

  3. Once connected to the session which might or might not respond, do the following. press "Ctrl + a" (there wont be any changes in your window now) type ":quit" ( its a colon[:] followed quit)

  4. Thats its your remote screen session will be terminated now.

  5. Hope this helps.



+ Recent posts