KEMBAR78
How to use tmux in Linux - A basic tutorial | PDF
Understanding
tmux
By Mohamed Gamal
© Mohamed Gamal 2025
What is tmux?
– tmux (short for Terminal Multiplexer) is a tool that allows you to manage multiple
terminal sessions from a single screen.
– It helps in multitasking by splitting windows into panes and maintaining sessions
even when disconnected.
$ sudo apt install -y tmux
Main Concepts
• Session → A collection of windows.
• Window → A full-screen terminal view.
• Pane → A split within a window.
1. Session Management
$ tmux
$ tmux new -s <session_name> # Create a session with a name
Start a new session:
$ tmux ls
List all sessions:
$ tmux kill-session -t <session_name> # t: target
Kill a specific session:
$ tmux kill-server
Kill the tmux server (end all sessions):
$ tmux a # Attach to the last session
$ tmux a -t <session_name> # Attach to a specific session
Attach to a session:
CTRL+b d
Detach from a session (without exiting):
CTRL+b $
Rename a session:
2. Window Management
CTRL+b ,
Rename the current window:
Next window: CTRL+b n
Previous window: CTRL+b p
Go to a specific window: CTRL+b <window_index>
List all windows: CTRL+b w
Switch between windows:
CTRL+b c
Create a new window:
CTRL+b &
Close the current window:
3. Pane Management
Horizontally: CTRL+b "
Vertically: CTRL+b %
Split panes:
Use arrow keys: CTRL+b ←/↑/↓/→
Show pane numbers: CTRL+b q, then press the number of the pane.
Navigate between panes:
Fine resize (single step): CTRL+b CTRL+←/→Coarse
resize (larger steps): CTRL+b ALT+←/→
Resize panes:
CTRL+b SPACE
Cycle through pane layouts:
CTRL+b x
Close the current pane:
4. Copy and Paste
Enter copy mode: CTRL+[
Scroll through text in copy mode: ←/↑/↓/→
Select text in copy mode: CTRL+SPACE
Paste copied text: CTRL+w
Exit copy mode: CTRL+]
Split panes:
CTRL+b ?
View tmux shortcuts in your session:
$ man tmux
Access the tmux manual:
5. Help and Documentation
Command Description
CTRL+b d Detach from the session
CTRL+b c Create a new window
CTRL+b , Rename the current window
CTRL+b x Close the current pane
CTRL+b q Show pane numbers
CTRL+b SPACE Cycle through layouts
CTRL+b ←/↑/↓/→ Move between panes
CTRL+b CTRL+←/→ Fine resize panes
CTRL+b ALT+←/→ Coarse resize panes
Command Description
CTRL+[
CTRL+]
Copy and paste text
CTRL+b ? Show tmux help menu
$ tmux ls List all sessions
$ tmux kill-session –t <session_name> Kill a specific session
$ tmux kill-server Kill all sessions

How to use tmux in Linux - A basic tutorial

  • 1.
  • 3.
    What is tmux? –tmux (short for Terminal Multiplexer) is a tool that allows you to manage multiple terminal sessions from a single screen. – It helps in multitasking by splitting windows into panes and maintaining sessions even when disconnected. $ sudo apt install -y tmux
  • 4.
    Main Concepts • Session→ A collection of windows. • Window → A full-screen terminal view. • Pane → A split within a window.
  • 6.
    1. Session Management $tmux $ tmux new -s <session_name> # Create a session with a name Start a new session: $ tmux ls List all sessions: $ tmux kill-session -t <session_name> # t: target Kill a specific session:
  • 7.
    $ tmux kill-server Killthe tmux server (end all sessions): $ tmux a # Attach to the last session $ tmux a -t <session_name> # Attach to a specific session Attach to a session: CTRL+b d Detach from a session (without exiting): CTRL+b $ Rename a session:
  • 8.
    2. Window Management CTRL+b, Rename the current window: Next window: CTRL+b n Previous window: CTRL+b p Go to a specific window: CTRL+b <window_index> List all windows: CTRL+b w Switch between windows: CTRL+b c Create a new window: CTRL+b & Close the current window:
  • 9.
    3. Pane Management Horizontally:CTRL+b " Vertically: CTRL+b % Split panes: Use arrow keys: CTRL+b ←/↑/↓/→ Show pane numbers: CTRL+b q, then press the number of the pane. Navigate between panes:
  • 10.
    Fine resize (singlestep): CTRL+b CTRL+←/→Coarse resize (larger steps): CTRL+b ALT+←/→ Resize panes: CTRL+b SPACE Cycle through pane layouts: CTRL+b x Close the current pane:
  • 11.
    4. Copy andPaste Enter copy mode: CTRL+[ Scroll through text in copy mode: ←/↑/↓/→ Select text in copy mode: CTRL+SPACE Paste copied text: CTRL+w Exit copy mode: CTRL+] Split panes:
  • 12.
    CTRL+b ? View tmuxshortcuts in your session: $ man tmux Access the tmux manual: 5. Help and Documentation
  • 13.
    Command Description CTRL+b dDetach from the session CTRL+b c Create a new window CTRL+b , Rename the current window CTRL+b x Close the current pane CTRL+b q Show pane numbers CTRL+b SPACE Cycle through layouts CTRL+b ←/↑/↓/→ Move between panes CTRL+b CTRL+←/→ Fine resize panes CTRL+b ALT+←/→ Coarse resize panes
  • 14.
    Command Description CTRL+[ CTRL+] Copy andpaste text CTRL+b ? Show tmux help menu $ tmux ls List all sessions $ tmux kill-session –t <session_name> Kill a specific session $ tmux kill-server Kill all sessions