TMUX/Screen Cheatsheet

TMUX and screen are extremely useful tools for maintaining sessions through reverse tunnels and other fragile connections. They allow for reconnection of sessions that become detached (disconnected) where the process is still running but there was some sort of network interruption.

They both have a very handy function where each window can be split either vertically or horizontally in to separate panes. I am not sure what the actual limit to the number of panes may be, but I regularly split my windows into four panes comfortably.

Screen is fairly ubiquitous in most Linux distributions, however TMUX is a program that will likely have to be installed on the machine you are connecting to. Screen is fairly old and does not get feature updates anymore (as far as I am aware), while TMUX is newer and has many plugins which can be used to extend its functionality. Learning both will ensure you are ready no matter which may be present on the system you log into.

^ is shorthand for the CTRL key, so ^b == CTRL + b.

-----

^a is the default meta-key for screen, while ^b is the default meta-key for TMUX.

Session Management

Action

TMUX

Screen

Start a new session

tmux

tmux new

tmux new-session

screen

Create a new named session

tmux new -s <name>

Re-attach a (local) detached session

tmux attach

tmux attach-session

screen -r

Re-attach an attached session (detaching it from elsewhere)

tmux attach -d

tmux attach-session -d

screen -dr

Re-attach an attached session (keeping it attached elsewhere)

tmux attach

tmux attach-session

screen -x

Detach from currently attached session

^b d

^b :detach

^a d

^a ^d ^a :detach

Detach and log out

^a f

^a ^f

List sessions

^b s

tmux ls tmux list-sessions

screen -ls

Pane Management

Action

TMUX

Screen

Split pane horizontally

^b "

^a S

Split pane vertically

^b %

^a |

Switch to another pane

^b o

^a tab

Kill the current pane

^b x

^a X

Close all panes except the current one

^b !

^a Q

Swap location of panes

^b ^o

N/A

Show time

^b t

-----

Show numeric identifier for all panes

^b q

-----

Window Management

Action

TMUX

Screen

Rename window

^b , <new_name>

^b :rename-window <new_name>

^a A <new_name>

Create new window

^b c

^a c

^a ^c

List windows

^b w

^a w

List windows (with selection menu)

-----

^a "

Go to window $num

^b $num

^a $num

Go to previously active window

^b l

^a ^a

Go to next window

^b n

^a n

Go to previous window

^b p

^a p

MISC

Action

TMUX

Screen

See key bindings

^b ?

^a ?

Enter "scroll mode"

^b [

^a [

Enter "Vim mode"

^b ]

Search with ?.

Hit [spacebar] to start copying text

Use ^b + ] to paste.

Scroll up in "scroll mode"

[page up]

[up arrow]

^b for page up

k for one line

Scroll down in "scroll mode"

[page down]

[down arrow]

^f for page down

j for one line

Exit "scroll mode"

q

ESC

Exit current shell

^d

^d

Ippsec Tmux Notes

Config from ippsec.

#set prefix
set -g prefix C-a
bind C-a send-prefix
unbind C-b

set -g history-limit 100000
set -g allow-rename off

bind-key j command-prompt -p "Join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "Send pane to:" "joian-pane -t '%%'"

set-window-option -g mode-keys vi

run-shell /opt/tmux-logging/logging.tmux

First press the prefix ctrl + b(default, Ippsec changes it to Ctrl+a) then release the buttons and press the combination you want.

Join panes: prefix + s #

Zoom in/out to panes: prefix + z

Kill session by tag:tmux kill-session -t X

Kill pane: prefix + &

tmux plugins:

If you like this content and would like to see more, please consider buying me a coffee!

Last updated