Using Screen and Tmux
Brief introduction to Linux multiplexers like screen and tmux.
Introduction
tmux and screen are terminal multiplexers. This means that both are command line utilities that let you run multiple shell sessions in one terminal, detach and reattach to sessions, and keep long-running tasks alive (even after SSH disconnection). This can be especially useful when working on remote servers. The two of them perform the same job, however in different ways, and you’ll find that some tasks work better in one versus the other.
screen Basics
Installation:
sudo yum install screenStart a New Session:
screenStart a New Session and Give it a Name:
screen -S mysessionDetach from a Session:
Ctrl+A, thenDList Sessions:
screen -lsReattach to a Session:
screen -r mysessionor if there is only one session runscreen -rKill a Session: from within a session
Ctrl+A, then type:quit. From outside of a sessionscreen -X -S mysession quit
tmux Basics
Installation:
sudo yum install tmuxStart a New Session:
tmuxStart a New Session and Give it a Name:
tmux new -s mysessionDetach from a Session:
Ctrl+B, thenDList Sessions:
tmux lsReattach to a Session:
tmux attach -t mysessionKill a Session:
tmux kill-session -t mysession
Useful Tmux Shortcuts:
Use the prefix Ctrl + B
Action |
Keys |
Desscription |
|---|---|---|
Split pane vertical |
“ |
Split window top/bottom |
Split pane horizontal |
% |
Split window left/right |
Switch pane |
Arrow keys |
Move between panes |
Create new window |
c |
Like creating a new tab |
Switch windows |
n/p |
Next/previous window |
List windows |
w |
Shows menu of windows |
Rename window |
, |
Renmae current window |
Close pane/window |
exit |
Just type exit |
Choosing Between screen and tmux
Generally, screen is a more basic, limited, and minimal screen multiplexer. It offers some customization and is generally easier to use. However, tmux is highly customizable and offers more advanced pane and window management, and scripting support. A more detailed analysis of the two can be found here.
Resources
Customize
tmuxmake tmux pretty and usabletmuxCheatsheet guide for easy referencetmuxManual in-depth guide to usingtmuxscreenBasic Usage basic usage guide forscreenscreenManual complete and indepthscreenguideGet the Most out of
screenshort guide with some customization options