Tuesday, April 14, 2009

linux screen command

Common screen commands

screen command Task
Ctrl+a c Create new window
Ctrl+a k Kill the current window / session
Ctrl+a w List all windows
Ctrl+a 0-9 Go to a window numbered 0 9, use Ctrl+a w to see number
Ctrl+a Ctrl+a Toggle / switch between the current and previous window
Ctrl+a S Split terminal horizontally into regions and press Ctrl+a c to create new window there
Ctrl+a :resize Resize region
Ctrl+a :fit Fit screen size to new terminal size. You can also hit Ctrl+a F for the the same task
Ctrl+a :remove Remove / delete region. You can also hit Ctrl+a X for the same taks
Ctrl+a tab Move to next region
Ctrl+a D (Shift-d) Power detach and logout
Ctrl+a d Detach but keep shell window open
Ctrl-a Ctrl-\ Quit screen
Ctrl-a ? Display help screen i.e. display a list of commands


configure:

harry@ubuntu:~$ cat .screenrc
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
# Default screens
screen -t root        0
# screen -t minicom       1 minicom
screen -t src1          1
screen -t src2          2
screen -t src3          3
screen -t shell1      4
screen -t shell2      5
screen -t telnet      6

1 comment:

Harry.Lau said...

ya, screen command is very useful especially for users who need to remote control a linux pc/server and always log off and log in.

because users can check what the process id is if it is detached and attach this process again without losing any running processes information.

it is also very good for users who want to open multiple terminals to work together. the split function is very useful in my eyes because i can watch the compiling information while i am editing source code in only one window. console can not do that at all.

but the inconvenience is apparent, it does not know what the current working directory is when open a new window which console taps can do well. another is the short cut key always conflict with other programs for example minicom. and the last, i dont know how to scroll up the screen if i want to see the previous information. so i have to set to log mode before getting any information i want to monitor.