Tmux and Screen

Tools that allow you to keep a command line process running if you lose connection to the remote system are useful if you are doing a long process like compiling or transfusing a large file. Tmux and Screen are two such tools.

Tmux

Tmux is a program which allows you to have persistent multiple "tabs" in a single terminal window.

Typical tmux workflow

Start a new session

tmux new -s s1

Once in the session, run any commands as normal.

Tmux has a large number of shortcut commands too. To access a shortcut, start with the control key in combination with the lower case "b" (ctrl-b). Then follow that with the shortcut option.

To detach the session so you can logout, go home and log in again later:

ctrl-b :detach

To get that same session back later:

tmux a -t s1 #get the same session back

Other useful tmux commands:

Create Panes and Synchronize with tmux

Screen

Screen is a Linux tool that provides the ability to launch and use multiple shell sessions from a single ssh session. When a process is started with ‘screen’, the process can be detached from session & then can reattach the session at a later time.

Typical Screen workflow

Start a new session

screen -S s1

Once in the session, run any commands as normal.

To detach the session so you can logout, go home and log in again later:

screen -d s1

To get that same session back later:

screen -r s1

To list all sessions:

screen -ls 

To kill a detached session:

screen -X -S session_name  kill

Screen has a large number of shortcut commands too. To access a shortcut, start with the control key in combination with the lower case "a" (ctrl-a). Then follow that with the shortcut option.

Other useful screen shortcuts:

Create Panes: