Screen/tmux

From HPC Wiki
Jump to navigation Jump to search

The tools screen and tmux are window managers. Their main purpose is to allow the user to perform multiple tasks in a Shell or during an ssh session at the same time. This is comparable to multiple tabs in a browser.

General

Screen and tmux allow to perform multiple tasks at once. An important concept is detaching and attaching: detaching means that you put a screen / tmux session into the background. You can later attach to any session which was detached (e.g. if you need the output of a command). Closed sessions cannot be attached to.

A huge advantage is that these commands decouple task and terminal: you can log into an ssh session, start screen (or tmux), and then start a long-running task (e.g. download a file via wget). Afterwards, one can detach the screen session and then exit the ssh session. The download is now still running in the background (without screen it would terminate when exiting the ssh session).

Using screen

If you want to start a new session, you will need to run:

$ screen

On the other hand, you can attach to existing sessions with:

$ screen -r [name]

where the name of the session is needed if more than one exist.

During a session, there are more commands. All of them require to type Ctrl + a. The most important commands are listed here:

Commands
c create a new window in the current screen session
space switch between the windows of the current screen session
d detach the current screen session

Using tmux

TODO