Bare Minimum Multi-Tasking Guide for the Terminal with Tmux

Sep 29, 2019 · 2 mins read
Bare Minimum Multi-Tasking Guide for the Terminal with Tmux

Have you ever-

  • SSHed to a server and felt the need of another terminal session because the current one was already running something?
  • SSHed to a server to run a long-running process but couldn’t close the terminal because it would terminate the process?
  • Wanted to wok with multi-window terminal like the picture above?
  • Wanted to continue from where you left off your terminal the last time?

If your answers to the questions are yes, then Tmux is the tool you need. Tmux is a multiplexer for the Linux terminal. In simple words, you can split a terminal and make multiple tabs in it with Tmux. There are many complete guides for Tmux. However, here I’m noting down the most important commands and the ones I use the most.

Installation

If Tmux is not installed, install it by running-

$ sudo apt  install tmux 
# or install with snap
$ sudo snap install tmux 

Commands

Create a new tmux session at first.

$ tmux #Create a new tmux session

You can do the following in a tmux session.

Ctrl+b c  Create a new window
Ctrl+b n  Go to next window
Ctrl+b 0  Switch to window 0 (do for any number of windows: 1, 2, 3...)
Ctrl+b w  Graphically switch window (choose from a list, also shows the snap of a session)
Ctrl+b x  Kill current window
Ctrl+b d  Detach session (doesn't terminate the session, simply gets out of tmux)

After detaching from a session you can attach to that session.

$ tmux ls               # See available tmux sessions
$ tmux a                # Attach to last used session
$ tmux a -t <session>   # Attach to a specific session from all available sessions (do "tmux ls" to view the sessions first)

Not necessary but useful commands

The above commands are all you need to take advantage of the most of tmux. However, if you want some terminal splitting, then-

Ctrl+b %                    Split terminal horizontally
Ctrl+b "                    Split terminal vertically
Ctrl+b [arrow keys]         Switch to another split screen
[hold] Ctrl+b [arrow keys]  Change size of the current split screen
Ctrl+b t                    Shows time!

Sharing is caring!