An Introduction to Tmux

If you are a command-line enthusiast, you have probably found yourself juggling multiple terminal windows or tabs. Enter tmux—a powerful terminal multiplexer that allows you to create, manage, and switch between multiple sessions, windows, and panes all within a single terminal. It’s especially handy for remote work over SSH, where you can detach from a session and reattach later without losing your work.

In this post, I will give you a quick rundown on getting started with tmux, including how to create sessions, detach and attach, and some basic navigation tips. Whether you are a beginner or just need a refresher, this should get you up and running.

Basic Commands Link to heading

Once installed, let us dive into the essentials.

  • Start a new tmux session:

    tmux
    

    This launches a new unnamed session. To give it a name (useful for managing multiple sessions):

    tmux new -s my_session
    
  • Detach from a session: Inside a tmux session, press Ctrl+b (the default prefix key), followed by d. This detaches you, but the session keeps running in the background—perfect for long-running processes.

  • List all tmux sessions (alias: ls):

    tmux list-sessions
    

    Example output:

    my_session: 1 windows (created Tue Aug 19 22:00:00 2025)
    
  • Attach to an existing session:

    tmux attach -t my_session
    

    If there is only one session, simply:

    tmux attach
    
  • Kill a session:

    tmux kill-session -t my_session
    

    To wipe out everything:

    tmux kill-server
    

tmux shines when you need to multitask. All commands start with the prefix Ctrl+b, then a key.

  • Create a new window: Ctrl+b, then c
  • Switch between windows: Ctrl+b, then n (next) or p (previous)
  • Split pane vertically: Ctrl+b, then %
  • Split pane horizontally: Ctrl+b, then "
  • Navigate between panes: Ctrl+b, then arrow keys
  • Close a pane: Ctrl+b, then x (confirm with y)

Why Use tmux? Link to heading

  • Persistence: Sessions survive disconnects, like SSH dropouts.
  • Efficiency: Handle multiple tasks in one window with splits and windows.

tmux has a bit of a learning curve, but once you get the hang of it, it will boost your productivity. For more advanced features, check the man page (man tmux) or the tmux wiki.