blog-image

May 01, 2017

7 min read

Tutorial: Get More From Terminals With tmux

Written by

Vippy The VPS
tmux is an open source "terminal multiplexer." Essentially, it allows you to switch between several programs within a single terminal—particularly useful on a VPS, when you can't simply launch another iTerm/xterm/etc window and attack the problem from another. Added benefits include being able to detach from a process while keeping it running in the background, and then reattach on another terminal. For a lot of dedicated Linux administrators, tmux is a must-have. It can be a bit overwhelming for those who are just getting started, so in this tutorial we'll walk through the basics of getting tmux set up, basic navigation, and a few possible configurations.

Prerequisites

  1. A VPS running Ubuntu, Debian, or CentOS
  2. Or, your local machine (running OpenBSD, FreeBSD, NetBSD, Linux, OS X, or Solaris)

Installing tmux

To install on an Ubuntu/Debian VPS, type in the following:
$ sudo apt-get install tmux
And on CentOS:
$ sudo yum install tmux

Managing sessions

The core of tmux is sessions. Here's where you can create separate environments that persist, even when you detach from them. For example, many developers like to create separate sessions for individual projects they're working on, or, if they work from home, they'll create a "work" and "home" session to keep things separate. Feel free to rename session to anything you would like.
Create a new session
$ tmux new -s session
Attach to an existing session
$ tmux attach -t session
$ tmux a -t session
Switch to an existing session
$ tmux switch -t session_name
List sessions
$ tmux list-sessions
$ tmux ls
Detach from the session
$ tmux detach
End a session
$ tmux kill-session -t myname

Using windows, aka tabs

Each session can contain a number of windows, which behave like tabs. You can create different windows for different commands or editors for dealing with files.
Create a new window
$ tmux new-window
Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply