首页 公告 项目 RSS

⬇️⬇️⬇️ 欢迎关注我的 telegram 频道和 twitter ⬇️⬇️⬇️


联系方式: Twitter Github Email Telegram

tmux Usage

August 5, 2025 本文有 277 个字 需要花费 2 分钟阅读

Introduction

tmux (terminal multiplexer) is a powerful terminal tool that allows you to manage multiple sessions, windows, and panes within a single terminal window. Whether you’re doing remote development, server management, or daily terminal operations, tmux can greatly enhance your efficiency.

Installing tmux

brew install tmux

Basic Concepts

  • Session: The top-level container in tmux. A session can contain multiple windows.
  • Window: Each window is like an independent terminal, capable of running different tasks.
  • Pane: A window can be further split into multiple panes for parallel multitasking.

Common Command Quick Reference

Operation Command/Shortcut Description
Start tmux tmux Create a new session
Exit tmux exit or Ctrl+b d Exit current pane/detach session
List sessions tmux ls List all sessions
Attach to session tmux attach -t <name> Attach to a specific session
New named session tmux new -s <name> Create and name a new session
Kill session tmux kill-session -t <name> Close a specific session

Note: The default prefix key in tmux is Ctrl+b. All commands require you to press this prefix key first, release it, and then press the corresponding command key.

Session Management

  • Create and name a new session
    tmux new -s mysession
    
  • Detach from session (keep running in background)
    Press Ctrl+b, then d.
  • Resume a session
    tmux attach -t mysession
    
  • List all sessions
    tmux ls
    
  • Close a session
    tmux kill-session -t mysession
    

Window Operations

  • New window: Ctrl+b c
  • Switch window: Ctrl+b n (next), Ctrl+b p (previous)
  • Rename window: Ctrl+b ,
  • Close window: exit or Ctrl+d

Pane Operations

  • Split horizontally: Ctrl+b "
  • Split vertically: Ctrl+b %
  • Switch between panes: Ctrl+b and arrow keys
  • Close pane: exit or Ctrl+d

Feel free to follow my blog at www.bboy.app

Have Fun