Skip to content

GNU Screen & Tmux

screen and tmux are terminal multiplexers. Screen is the classical one (since 1987), and tmux is a more modern variant on the same principle (since 2007).

What problems does it fix

  • You have a long running process, and you don't want it to stop when you log out
  • You have an unstable connection, and each time you lose connection your process stops.
  • You want to split your terminal into two smaller terminals (not explained on this page).

What is it

GNU screen and tmux provide a way to start processes that are not dependent on your SSH session. In simple terms: your process does not stop if you log out or lose connection. You can think of it as a browser with tabs, where you can start, stop and switch between tabs. The idea is that you open such a tab ('screen session', in the terminology), start your script, detach to go do something else (or log out), and then later reattach to this process to see what is has written to terminal.

How does it work

  • Start a session: screen -S session_name or tmux new -t session_name
  • Detach from a session: Ctrl+a d (tmux default: Ctrl+b d)
  • List screen sessions: screen -ls or tmux list-sessions
  • Reattach to an existing screen session: screen -r session_name or tmux a -t session_name
  • Reattach to an existing sessions that you already attached to: screen -rD session_name
  • Stop the current screen session: Ctrl+D

There is much more for screen: https://gist.github.com/fredrick/1216878 And for Tmux: Tmux Tutorial