Table of Contents
This tip is about the how to Use tmux on Linux. So read this free guide, How to Use tmux on Linux step by step. If you have query related to same article you may contact us.
How to Use tmux on Linux – Guide
Terminal Multiplexer (TMux) is an acronym for Terminal Multiplexer. A process is a computer program that is actively operating. With Linux, you will need more than one terminal window to run multiple processes: one terminal window per task. These windows will almost completely hide from each other. To pay attention to a procedure, click on the window to bring it to the front of the screen. Once you’re front and center, you can look at some results or enter data. Multitasking is when you run many processes at the same time, in this example with multiple windows. Tmux is not needed for multitasking. Tmux offers a superior alternative in the form of multiplexing.
Each window uses a shell like Bash. Program commands must be typed into a shell before they are executed. Tmux is software that solves these problems. This article covers how Tmux addresses these issues and looks at some of the other features of Tmux.
Installing Tmux on Linux
Perhaps Tmux is already installed on your computer. So you should make sure it is installed first so you don’t reinstall. At the terminal command prompt, type
and press Enter.
If it is not installed, it will let you know. If it is installed you will get comments like,
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name][-S socket-path] [command [flags]]
The commands in this tutorial were tested with Ubuntu and worked fine. So if you are using Ubuntu OS, you can test the commands as you read.
Installing Tmux on Ubuntu and DebianTo install on either of these operating systems, type
and press Enter. If it asks for your password, type your password and press Enter.
Installing Tmux on CentOS and FedoraTo install on CentOS or Fedora, type
and press Enter. Answer any questions that are asked.
Starting Tmux
Tmux is a utility that must be started before it can be used. When you open the terminal window, Tmux is not running. It can be started and stopped. When it starts, it takes control of the terminal window and overlays its own windows. Once it’s stopped, you’ll be back in the terminal window. To start Tmux, type
(all lowercase characters) and press Enter. You will have a new window. Tmux would take over the new window. The new window looks like the terminal window, but with a status bar at the bottom. In this situation, the status bar indicates that you are in Tmux window 0, shown as 0:bash (if using the Bash shell).
The default key combination for Tmux is:
ctrl+b
You press the control key and the lowercase b character, and as soon as you release the keys, press some other character to affect. To display the list of Tmux commands, type
ctrl+b ?
That is, press the control key and the character b at once, and once you release both keys, press shift and the ? Key (if you are using English keyboard). You should see the list of commands. The list is quite long. The cursor would be at the top. You can use the down arrow key to scroll the list.
To exit the list screen, press
q
and you will be back at the command prompt.
Leaving Current Window To exit the current window, type
and press Enter. You will see
Indicating that you have exited the Tmux application (if only one Tmux window has been opened). You should be back to the normal terminal window if you only have one Tmux window. If you run the “exit” command again, the normal terminal window will close.
Creating more than one Tmux window
In the above section, only one window was created. When you start Tmux, a window (0:bash) is created. You can create more. If you didn’t open the terminal window, open it and start Tmux by typing,
and pressing Enter. The terminal window should change into a Tmux window, the first Tmux window. Create three more canvas windows by typing the following commands and pressing Enter, where c is lowercase (and doesn’t need the shift key):
ctrl+b cctrl+b cctrl+bc
For each of the commands, you press the control key and the b key (in lowercase); release those keys and then just press the c key. It may take some short experience to get it right. If you have successfully executed all three commands and if you are using the Bash shell, in the status bar you should see
[0] 0:bash 1:bash 2:bash-3:bash*
[0] means session 0. The rest of the line means that you have opened four windows, which are 0:bash, 1:bash, 2:bash and 3:bash. The Tmux window count starts at 0.
To go to any other window, run the following command:
ctrl+bs
You should see a different presentation, a list of Windows presentations. You can highlight the window label you want using the left arrow key or the right arrow key on the keyboard. Use the right arrow key to choose window number 1, which is actually the second window, and press Enter.
If you typed any commands in the second window, you should see the commands in the window. In the status bar, you should also see 1:bash*. the asterisk
indicates the window you are in, and in this case it is window number 1, which is actually the second window.
You can continue typing the commands you want in this second window. You can switch to some other window in the same way.
Switching to other windowsYou can switch to another window using the above method. There is another method: To switch to window number 3 (the fourth window), run
ctrl+b 3
You must have it now,
With the asterisk in the status bar, which means you are in the fourth window. So to go to a new window you can do “ctrl+b index”, where an index is an ordinal number minus one.
Going to Next and Previous Windows To go to the next window, do
ctrl+bn
If you were at the second window, you would arrive at the third window. If you were at the last window, you would arrive at the first window. To go to the previous window, do
ctrl+bp
If you were at the first window, you would arrive at the last window.
Listing all windows To list all windows, do
ctrl+bw upIn the list that appears, you will be able to choose the next desired window, with the keyboard
-arrow or down arrow. After highlighting, press the Enter key to enter the chosen window.
Exiting a WindowTo exit a window type,
and press Enter. You can exit all windows by repeatedly running the exit command. If you do this the number of times, corresponding to the number of Tmux windows, you will get to the terminal window, which has been taken over by the Tmux utility; and you will see:
If you run the exit command again, it will close the terminal window.
Final note
I hope you like the guide How to Use tmux on Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.