tmux

tmux - Terminal Multiplexer

tmux is a terminal multiplexer. It helps switch between multiple programs in one terminal, detach them(they keep running in the background) and reattach them when needed. I started using tmux as someone recommended me to start using it as it helps with CKA & CKAD (which I have still not attempted) and then later on I was heavily using it for my website(with Hugo). I had previously used mPutty, but mPutty uses multiple logged-in sessions to display on the screen, whereas tmux simply multiplies the existing sessions on screen.

Installation

Major distribution of Linux provides tmux packages via standard pre-built packages of tmux.

PlatformInstall Command
Debian or Ubuntuapt install tmux
RHEL or CentOSyum install tmux
macOS (using Homebrew)brew install tmux

Basic commands and usage

CommandDescription
tmuxstart a new session
tmux new -s my-kube-sessionstart a new session with name
tmux aattach
tmux a -t my-kube-sessionattach to a named session
tmux lslist all tmux sessions
tmux kill-session -t my-kube-sessionkill the session named my-kube-session

After a session is created, inside to perform any action, we need to hit ctrl+b followed by any below command/keystroke

KeystrokeDescription
ctrl+b -> ccreate new shell
ctrl+b -> nnext shell
ctrl+b -> pprevious shell
ctrl+b -> ddetach session
ctrl+b -> %vertical split
ctrl+b -> "horizontal split
ctrl+b -> [arrow keys]to switch between the vertical/horizontal panes
ctrl+b -> zzoom in and zoom out between split panes

That’s all more or less the keystroke you need to know; It comes off naturally when you start using it after a few days but until then - you can refer to these as needed.