If you work on terminal a lot, you might find screen is useful. Screen provides a virtual terminal which supports multiple windows, copy paste, etc. and it’ll continue to run after you have closed the real terminal you are working on. It’s distributed with most Linux distro so it’s most likely that you won’t have to install it. Just type screen to run. If it was not pre-installed or you want to update it to latest version you can try:

Fedora: sudo -c “yum install -y screen”

Ubuntu: sudo apt-get install screen

After you have started screen just type echo $STY. If you see something like 3002.pts-0.localhost you’ll know that you are inside a screen.

The features that I find most useful of screen are creating/switching/closing windows and copy paste. Let’s try these first.

Multiple windows

If you press Ctrl+a Ctrl+c (keep pressing Ctrl while you press a and then c) you can create a new screen. To switch between windows, you can try Ctrl+c Ctrl+” (double quotes) to show windows list, use arrow keys to navigate around, and then press Enter to select the windows that you want. An alternative method is to press Ctrl+[0-9] to activate the windows you want to (start from 0).

Copy paste & screen scrolling

If you want to copy paste a part on the screen, press Ctrl+a Ctrl+[ to activate copy-paste mode. After that you can use arrow keys to move around. You may use space to mark the start point and the end point. After you have marked the end point copy-paste mode will be deactivated. You also can deactivate this mode using ESC key (I often use this to scroll up and down the current window). Pasting can be done simply by pressing Ctrl+a Ctrl+]

Starting, detach and resume a screen session

To detach from a screen session, you can press Ctrl+a Ctrl+d (detaching). The screen will continue to run in the background. You can quit screen completely by Ctrl+a Ctrl+\

If you want to resume a screen session that running in the background, type screen -dr into the terminal.

Further reading

Now you knew enough to use screen. There are many more features in screen user manual at: http://www.gnu.org/software/screen/manual/screen.html

Advertisements