• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install And Use Tmux

Written by Admin, Updated On May 16, 2020
terminal, tmux
Getting started with Tmux

This tutorial explains how to install and basic use of Tmux.

What is tmux?#

Tmux is a terminal multiplexer. It allows you to access a tmux terminal using multiple virtual terminals. It means within one terminal window you can open multiple windows and split-views. Each window occupies the entire screen and can be split into rectangular panes.

This also means that sudden disconnects from a server running tmux will not kill the processes running inside the tmux session.

tmux is an alternative of GNU Screen.

Installing Tmux#

Installing tmux is pretty straightforward on most distributions.

Install Tmux on Ubuntu and Debian#

sudo apt install tmux

Installing Tmux on CentOS and Fedora#

sudo yum install tmux

Install Tmux on macOS#

brew install tmux

Starting Your First Tmux Session#

For your first session simply start tmux with a new session:

tmux

This will create a new tmux session and start a shell in that window. This window shows a green status bar with information about current session.

You can now run your first tmux command. For example, to get a list of all commands, you would type:

Ctrl+b ?

Creating Tmux Session with Name#

When have multiple sessions, it is difficult to find. We can create session by giving name which will be very useful to identify. To create a session with name, run tmux command as following:

tmux new -s session_name

Here, you should replace session_name with your appropriate name.

Working with Tmux Windows and Panes#

Type Ctrl+b c in shell to create a new window. A list of all windows is shown on the status line at the bottom of the screen.

Below are some most common commands for managing Tmux windows and panes:

  • Ctrl-b + c Create a new window (with shell)
  • Ctrl-b + w Choose window from a list
  • Ctrl-b + 0 Switch to window 0 (by number )
  • Ctrl-b + , Rename the current window
  • Ctrl-b + % Split current pane horizontally into two panes
  • Ctrl-b + " Split current pane vertically into two panes
  • Ctrl-b + o Go to the next pane
  • Ctrl-b + ; Toggle between the current and previous pane
  • Ctrl-b + x Close the current pane

Detaching from Tmux Session#

To detach from the Tmux session and return to your normal shell type:

Ctrl+b d

It will keep continue program which are running on the Tmux session.

Re-attaching to Tmux Session#

You can attach to a session by name so we need name of the session first. To get a list of the currently running sessions type:

tmux ls

The name of the session is the first column of the output.

0: 1 windows (created Wed May 14 17:30:14 2020) [158x35]
copy_session: 1 windows (created Wed May 15 18:17:18 2020) [78x35]

Above you can see there are two running Tmux sessions. The first one is named 0 and the second one copy_session.

For instance, to attach to session copy_session, you would type:

tmux attach-session -t copy_session

Conclusion#

In this tutorial, you learned how to use Tmux to resume the sessions even after disconnected. Now you can start use of the Tmux to create multiple screen windows from a single session, detach and resume screen sessions.

To learn more about Tmux visit Screen User’s Manual page.

Feel free to leave a comment if you have any questions.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Add Swap Space on Ubuntu 20.04
Next Article   How to Install Ruby on CentOS 8 / RHEL 8

Related Posts

  • How to Use sed to Find and Replace String in Files

    How to Use sed to Find and Replace String in Files

    December 18, 2020
  • Linux Head Command

    Linux Head Command

    December 16, 2020
  • Rename Files and Directories in Linux

    How to Rename Files and Directories in Linux

    December 15, 2020

Leave a Reply Cancel reply

Popular Posts

© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook