The Wayback Machine - https://web.archive.org/web/20240922223358/https://www.geeksforgeeks.org/how-to-use-tmux-terminal-to-access-multiple-terminals-inside-a-single-console/
Open In App

How to Use ‘Tmux Terminal’ to Access Multiple Terminals Inside a Single Console

Last Updated : 29 Jan, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

tmux, or Terminal Multiplexer is a command-line tool for managing multiple terminal sessions in one window. It’s beneficial for developers and system administrators, offering features like splitting the terminal into panes, creating sessions with windows and panes, customization, scripting, and remote access. Users can organize tasks efficiently, customize their environment, and automate repetitive tasks. tmux is particularly useful for remote work, allowing detachment and reattachment to sessions. It’s initiated by typing ‘tmux’ in a terminal, with commands for creating panes, and windows, and customizing the environment.

One of its important features is the ability to split the terminal into panes, allowing users to handle multiple tasks at the same time within the same window. This article provides a step-by-step guide on opening and managing multiple panes in tmux.

Why do we need multiple tmux Panes?

Many terminal users find it challenging to easily manage multiple tasks concurrently. For example, suppose you are running tests for your application and also need to keep an eye on system resources. Tmux simplifies this by splitting the panes. Now you can run tests in one pane while monitoring system resources in the other.

Another example: Let’s say you are working on a web development project, and you need to run various commands to manage your project, such as running a version control system like Git managing dependencies with npm, and monitoring server logs. tmux panes can be valuable in this situation. You can have one pane for running Git commands or managing dependencies with npm and another for monitoring server logs. This way, you can easily switch between these tasks without needing to open multiple terminal windows or tabs.

tmux-panes
tmux Panes.

Opening and working with multiple panes at the same time in tmux.

Method 1: For splitting the current pane vertically, use `Ctrl+b` followed by `%`. To split horizontally, press `Ctrl+b` and `“`.

Step 1: Open the terminal and, if not already installed, install tmux using the following command:

sudo apt install tmux

Installing tmux.
Installing tmux

Step 2: Open the terminal. Connect to a remote computer if you are using one. Launch tmux with `tmux` command.

tmux

running tmux
running tmux

Step 3: Vertical Split

For a vertical split, press `% ` after `Ctrl+b.` This action will split the current pane into two vertical panes, effectively dividing the terminal window.

vertical-split-of-tmux-pane
Vertilcal split of tmux pane.

Step 4: Horizontal Split

To split the pane horizontally, press `“` after `Ctrl+b` . This will create two horizontal panes within the terminal window.

Horizontal-splitting-tmux-panes
Horizontal split of tmux pane.

We can also split the already divided panes further by navigating through the split panes and using the same command for splitting.

Method 2: Another method for splitting the screen vertically within tmux is to use the command `tmux split-window -v`. To split the screen horizontally, execute the command `tmux split-window -h` within a tmux session. Let’s understand this with following image representation:

splitting-panes
splitting panes using `tmux split-window`

Method 1: To navigate through split panes in tmux, press `Ctrl+b`and then use the arrow keys to move between panes within the current window.

navigating-in-tmux-panes
Navigating split panes in tmux.

Method 2: To navigate through split panes in tmux, press `Ctrl+b`, and then press `o` to toggle between the split panes.

Method 3: Press `q` after pressing `Ctrl+b`, and you will see the index of all the split panes. To switch to a particular pane, press the respective index, and you will be directed to that specific pane.

using-ctrl-b-and-q-in-tmux
using `ctrl+b` and `q` in tmux

In the image, you can see that after pressing `q` following `Ctrl+b`, the index of all panes is displayed in every pane. To switch to a specific pane, press the corresponding index.

Closing the split panes in tmux

Method 1: To close a specific split pane in tmux, simply type the command `exit`, and the pane will be closed.

closing-tmux-panes
Closing the split panes in tmux.

Method 2: Another method for closing panes in tmux is to press “x” after pressing Ctrl + b. This action will close the current active pane.

Closing the tmux session

Method 1: To close a tmux session, the exit command is used.

closing-the-tmux-session
Closing the tmux session using ‘exit’ command

Conclusion

The step-by-step guide outlined here gives a brief overview of how to open, navigate, and close panes in tmux. This tool is essential for handling multiple tasks simultaneously, simplifying complex activities without requiring extra terminal windows. Learning tmux shortcuts can greatly enhance user productivity, making it a valuable addition to the command-line toolkit.



Similar Reads

How to Open Multiple Terminals in Ubuntu
As a programmer or developer, we may feel insufficient to use only one terminal or window. We need more than one terminal to easily navigate through code files or do another installation task. This problem is also faced by the system administrators as well as the DB administrators because we may need more than 2 terminals to handle the system effic
5 min read
How to write a shell script that starts tmux session, and then runs a ruby script
Scripts are important for streamlining workflows and automating tasks. One such way to streamline workflow is by using Tmux [Terminal Multiplexer]. When used along with shell scripts we will be able to automatically commence a Tmux session and perform certain tasks. In this article, we shall see how to use a shell script that will automatically sta
4 min read
How to Set tmux for Opening Specified Windows at Startup?
In Linux to open specific windows at startup, we can configure the tmux utility. We need to modify the tmux configuration file in the system which will allow us to create windows and also specify the layout. To make sure that windows open when tmux starts, we can include the special command at the end of the configuration which will ensure the prop
4 min read
Working with tmux session
tmux is software application providing a command line interface and also allowing user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. While you work with Amazon Web Services(or any other cloud computing platform like Google Cloud Platform or Microsoft Azure) it helps to create a separate se
2 min read
How to Create tmux Session with a Script
Managing terminal sessions efficiently is crucial for developers and system administrators. tmux (short for terminal multiplexer) is a powerful tool that allows you to create and manage multiple terminal sessions within a single window. It is particularly useful for working on remote servers or handling long-running processes. In this article, we w
6 min read
Tmux in Linux
Tmux is a short form for "terminal multiplexer,". It is a powerful command-line tool in Linux that enables users to manage multiple terminal sessions within a single window. It allows for the creation and manipulation of multiple panes and windows, facilitating multitasking and efficient workflow organization. Tmux is particularly useful for remote
9 min read
MacOS Tmux Plugins Not Working? Here’s How to Fix It
Tmux is like a magic box for your computer's terminal. It helps you manage many little windows inside one big window. So, instead of lots of small windows everywhere, you can have them neatly organized in one place. It's like having lots of terminal screens inside one terminal. Users can split the window into different sections, switch between task
4 min read
Shell Script to Find How Many Terminals Has User Logged-In
Here we are going to see Find How Many Terminals Has User Logged In. Using who command to fetch the user list and then using grep command we can find the number of Terminal that the user has logged in the Linux. We can use LOGNAME or UID to identify the user. UID is a unique User ID assigned to every user that logged in the system, it is an integer
2 min read
What is Terminal, Console, Shell and Kernel?
As a fresher, while learning Linux we get confused with the actual meaning of the terms like-Terminal, Console, Shell, and Kernel. Sometimes we mix up their usage which is technically incorrect so having a clear grasp of what every word actually means and how and where they should be used is very important. 1. Terminal:For those having Linux OS, wh
4 min read
How to zoom in and zoom out terminal console in linux
Linux is a Debian-based Operating system used by many professionals and other people for various purposes. Mainly Linux is used for Penetration testing and Vulnerability assessment. Windows systems often interact with GUI (graphical user interface) but in Linux, we use a terminal console more to interact with the system and to do things normally. I
7 min read
How to Comment and Uncomment multiple line vi terminal editor
The Vi and Vim text editors are powerful tools widely used by programmers, system administrators, and writers for efficient text manipulation and editing. A common task that often arises during coding or text management is the need to comment or uncomment multiple lines of code or text. Commenting helps in annotating code for better understanding,
3 min read
How to Install and Use Alacritty Terminal Emulator in Linux?
Alacritty is a cross-platform terminal emulator with GPU acceleration. It's a terminal emulator for OpenGL written in the Rust programming language. Alacritty is the fastest and lightest Terminal emulator in nature, thanks to its OpenGL renderer and high throughput parser. Alacritty Terminal emulator does not have many fancy features like tabs and
2 min read
How to Use Terminal in Sublime Text Editor ?
Well in Visual Studio Code we get a direct Option for opening Terminal, Unlike Sublime Text editor. Sublime is Simple and free to use, Light on memory, and can easily work with multiple projects. In this article, we will see how to use Terminal in a Sublime Text Editor. This article will answer all your queries such as How to use Command Line in Su
3 min read
How to use exit code to read from terminal, from script and with logical operators
Scripting is an important part of automation in Linux and it is one of the key tools every system administrators use to manage day-to-day activities like taking backups, adding/removing users/groups, updating/removing packages, etc. Since bash is the default shell in most of the Linux distributions, bash scripting is very efficient as it can simpli
7 min read
How to Use Twint OSINT Tool on Google Cloud Console ?
TWINT is an advanced Twitter scraping tool written in Python that allows for scraping Tweets from Twitter profiles without using Twitter's API. Twint utilizes Twitter's search operators to let you scrape Tweets from specific users, scrape Tweets relating to certain topics, hashtags, and trends, or sort out sensitive information from tweets like e-m
3 min read
How to Run Multiple Virtual Machines Windows and Linux Inside VirtualBox?
Virtual Machines are the software applications/files which emulate the physical computers. This process of emulating a physical computer and making able to run instances of it on a single physical machine is called Virtualization. A Virtual Machine (VM) allows us to run multiple or different Operating systems on a single physical machine and share
11 min read
Cool Custom Welcome Messages on Linux terminal
There is a Linux hack which can be used to display a custom message on the terminal every time we open it. This can be done by manipulating the .bashrc shell script. What is .bashrc ? It is a shell script that Bash runs whenever it is started interactively. You can put any command in that file that you could type at the command prompt. Steps on how
3 min read
Custom commands for linux terminal
Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable. Syntax : $ nano ~/.bashrc Here, bashrc means run the Bash file. Bash is located at /bin/bash . This file helps in c
2 min read
How to copy a file's content from Linux terminal?
This article shows the alternative method to copy the content of the file onto the clipboard, via the Linux terminal. In OSX, the commands pbcopy and pbpaste are available by default. Thus, to copy a file onto the clipboard via OSX terminal, type: pbcopy < 'path of the file' Since, in Ubuntu, pbcopy and pbpaste commands are not availab
2 min read
How to Browse From the Linux Terminal Using W3M?
W3M is an open-source text-based terminal web browser for Linux used to browse through the terminal. It is simple to use and do not require any additional interacting interface application though it interacts through the terminal. It renders the web pages in a form as their original layout. How to Install W3M? As W3M is not included by default on m
1 min read
Using Lynx to Browse the Web From the Linux Terminal
Lynx is a terminal-based web browser for all Linux distributions. It shows the result as plain text on the terminal. It is a classic non-graphical text-mode web browser which displays the pages on the terminal. Lynx does not load images and multimedia contents, hence it is fast as compared to other browsers. One who do not want so many images and m
2 min read
Few Tips for Fast & Productive Work on a Linux Terminal
This article is aimed at making you more productive and waste less time on running commands by providing you the information about Linux Terminal's Shortcut & Tricks. In simple words, less time you take to complete a task the more professional you become! 1. Opening the Linux Terminal (Ubuntu): The Linux terminal can be opened from a window or
4 min read
Shortcut to Move to the Beginning or Ending of a Command in Linux Terminal
In this article, we will learn how to move to the start and end of a command. We will demonstrate the key combinations in a Git terminal. The same key combinations work in other Unix style terminals too. Moving to the Starting of the Command Ctrl + A : The 'Ctrl+A' key combination moves the pointer to the start of the command. In the below gif imag
1 min read
Ttyper - Test you typing speed in terminal
Ttyper is a command-line tool that is built with Rust and tui-rs.ttyper can test your typing speed. This tool is not working for the English language, but it also checks your typing speed in the programming languages like C, CPP, HTML, Java, and many more programming languages. Now let's see how to install the ttyper on the Linux, Windows, and macO
3 min read
Kali Linux - Terminal and Shell
Generally, operating systems have 2 interfaces GUI(Graphical User Interface) and CLI(Command Line Interface) and the same is the case with Linux Based Operating Systems. Linux Operating Systems are generally packed with terminal emulator packages for CLI based functioning and Desktop environment packages for GUI based functioning. Some common ones
3 min read
Basic System Controls with Terminal in Linux
Sometimes some of the basic services of the system stop working or starts malfunctioning. And it becomes really difficult to solve the problem through Graphical User Interface so here is the list of Terminal Command to solve the problem and to control the basic services manually. Installing the required packages To control the basic system services
2 min read
Interesting Commands on Mac Terminal
Terminal is one of the most important tools in MacOS be it any field. To get good knowledge about the terminal is important. It teaches you many things in an innovative way which is liked by most of the developers. It's a knowledge that only geeks and geniuses have. Here are some commands with the most impressive features. The commands used below m
2 min read
10 Best Linux Terminal Emulators
Despite various GUI advancements, Terminal Emulators have still an adequate presence in the tech market. A terminal emulator is software that allows to you interact with the host machine with the help of commands. Terminal Emulator is a lifeline for every Linux distro as it enables you to utilize the real strength of Linux. For developers, their ma
7 min read
How to Install Tilix Terminal Emulator in Ubuntu/Fedora/Arch Linux?
A terminal emulator is a software that helps in interacting with the computer machine and perform operations using commands. Tilix is a tiling terminal emulator formerly known as Terminix. It is an enhancement over a regular terminal and provides some important features. Features of Tilix Terminal Emulator: Enable users to split the terminal into d
3 min read
How to Search DuckDuckGo from the Linux Terminal?
DuckDuckGo is a search engine like Google, but it takes more care about user search protecting its privacy. To search from a terminal there is one tool called ddgr. This tool provides us the ability to search from the terminal by using the DuckDuckGo search engine. Installation of ddgr Required tools for ddgr installation: Python3.3 or later.Python
2 min read