Virtual Terminals
GNU Screen
GNU Screen is a program that allows you to create a virtual terminal session inside a single terminal window. It is useful for dealing with multiple programs from a command line interface and for separating programs from the Unix shell that started the program.
To start screen, simply type
1 |
|
at the command prompt. Even if it looks like nothing has happened, you are now in a new window within screen. Describing the details of how screen works is beyond the scope of this entry, but it allows you to leave a session running even after you've logged out (or disconnected because of network issues).
One challenge with the 'screen' command is that by default you can't load any modules or other system commands. That's because 'screen' does not run the shell profile commands (in /etc/profile and /etc/profile.d). HPCC configures the modules system and several other system variables/settings in these profile scripts. Without running them, the module system won't work.
However, you can ask screen to run this profile by including the line shell=-$SHELL in the screen config file ".screenrc" in your home directory. To make a screen config file, try this (provided you don't already have a .screenrc file)
create default .screenrc
1 |
|
You'll have to exit and restart screen to see the changes.
Screen Commands
To send commands to screen (instead of the window you're working in), you preface them with Ctrl-a, i.e., you type the Ctrl key and "a" together, release both keys, then type the next letter to invoke the command.
-
Ctrl-A then:
? Display available screen commands " List running screen windows N Display number of current window c Open a new window [number] Switch to window [number] [ Copy (so you can paste to another window) ] Paste k Kill the current window Ctrl-\ Quit and close all screen windows A Label the screen window M Monitor for activity d Detach the current screen session -
Startup commands:
screen -ls
List detached screen sessions on the server screen -S (name for new screen) Create a screen with specified name screen --r [id]
Reattach the specified screen
Detaching/Reattaching Screen Sessions
To detach a running screen session, type
Ctrl-A d
This will detach the screen session with all of its windows but leave
all of the related processes running. You can start and detach as many
screen sessions as you wish, each with its own windows and processes.
You can even logout of the server, and your screen sessions will
continue running while you're gone.
To reattach a screen session, find the id of the one you want with
screen -ls
then reattach it with
screen -r id
If you don't remember which screen sessions you have opened on our cluster, you can type:
1 2 |
|
If you are running a licensed software (such as MATLAB) within a screen session, please remember to kill it when you're done developing for the day. This will help us better manage licenses for the MSU research community.
Screen customizations
The attached file (click here) includes customizations to screen that places an information bar at the bottom of the terminal. Many people find it very usefu. View the file and copy selected or all lines to your ".screenrc" file.
Tmux
tmux is intended to be the modern, BSD-licensed alternative to screen. Both programs are available on HPCC. It allows splitting a window horizontally and vertically, and copying and pasting between multiple buffers. More information is available at http://tmux.sourceforge.net.