Get more screens … with screen

Tired of switching back and forth between local and remote terminal sessions by logging in and out? Then screen is (one of) the tool (s) for you!

screen will be available on most Linux systems, including the PSU clusters. It is also available as a package in Cygwin. Once you have it installed, try the following sequence of steps:

1. Open a terminal window and type screen. A welcome message will be displayed. Your terminal window is now running the screen program, even though you may not notice a difference.

2. Press (Ctrl+a c) — that is, hold down Ctrl, then press a and c. This will create a new “screen”. Note that all screen commands start with Ctrl+a by default.

3. You now have two “screens” running. To see this, press (Ctrl+a w) to display the list of open windows. In Cygwin, this will display in the top bar of your terminal. There will be an asterisk next to the window you’re currently in.

4. Press (Ctrl+a n) to toggle through your “screens”. Try ssh-ing into a remote system in one of the screens, then switching back to the other screen on your local system. This is a great way to avoid logging in and out every time you need to move between systems!

5. You can close a single screen by pressing (Ctrl+a K) (note the capital K). You can quit the whole screen program by running screen -X quit.

There are many other things you can do with this. I just discovered it not long ago, although I suspect the more Linux-minded people among us have known about it for a while. There is a more comprehensive list of commands available here: http://kb.iu.edu/data/acuy.html

Thanks for reading, and feel free to add to this post if you learn/know some good tips.

Advertisements

2 thoughts on “Get more screens … with screen

  1. I’d like to mention my favorite screen feature: If you start screen on the cluster and your network connection drops out (say your laptop goes to sleep), you can reattach your screen session with screen -R It’s as if you never logged out.

    You can also detach your screen session on purpose with screen -d and come back to what you were working on by using screen -R later. So if I’m doing something on the cluster from my desk and I realize it’s time to go home, I can detach, go eat my dinner, and then reattach the same session from my laptop at the kitchen table later in the evening.

    Also, it’s a little trouble to set up, but there’s a great reimplementation of screen called tmux. It can do some really neat split-screen stuff that screen can’t. Unfortunately it doesn’t run under Cygwin, and it’s not on the cluster by default, but it was pretty easy to compile and run it from my home directory.

    [edit: formatting]

  2. Pingback: Water Programming Blog Guide (Part I) – Water Programming: A Collaborative Research Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s