Tip 1: Screen

From Vlsiwiki
Jump to: navigation, search

GNU screen is a terminal multiplexer. It lets you have multiple shells in the same window. It is kind of like "tabs" but without the tabs. The other advantage is that you can detach and reattach to a screen session at a later time. This is very useful when you are running a bunch of things or have buffers open for editing and want to save your terminal state (like working directories, bash history, etc.)

1) To start a screen, just type "screen". It will invoke a new empty shell. All screen commands are prefixed with "Ctrl-a". This is a bit awkward at first, but you get used to it. Type "ls" just to add some output to the window.

2) To create a second window, type "Ctrl-a c" for create new. This will make window 1 and switch to it.

3) To switch back to window 0, type "Ctrl-a 0". To go back to window 1, "Ctrl-a 1". You can also cycle to the next and previous windows with "Ctrl-a n" and "Ctrl-a p", respectively.

4) To detach from the screen, type "Ctrl-a d". This will go back to your original terminal where you ran "screen" but everything else is STILL RUNNING.

5) To get a list of your screen sessions, type "screen -ls". You will get a list of the attached, detached, or broken screens (this happens if you have a screen running and the machine is rebooted).

6) Note that you can actually attach to a single screen simultaneously from multiple places! Executing "screen -D -R" will Reattach and force Detach from all other terminals.

The one disadvantage of screen is that it is a terminal only so you cannot run X applications.

For more information:

http://www.kuro5hin.org/story/2004/3/9/16838/14935

or

man screen