Linux Tmux Tutorial With Command Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-tmux-tutorial-command-examples/
PINTEREST
PINTEREST
INSTAGRAM

Tmux is terminal multiplexer popular in Linux world. Tmux provides multiple windows in a single session. Tmux also have the ability to detach and run after disconnect and attach after connection. This is very useful for system administrators.

Man

Man page of tmux provides a lot of detailed features. To get more information man page of tmux can be used like below.

Start Tmux

Tmux is a terminal emulator acts like a shell. Tmux can be started like a shell too. Just run tmux command we will get tmux screen by clearing existing shell screen.

Start Tmux
Start Tmux

Bind Key

Tmux uses  CTRL+b for operation key which means to use shortcuts of tmux CTRL+b should be prefixed with related keyboard shortcut

List Current Key Bindings

Tmux mainly used with keys with bind keys. These key bindings can be listed with following command. As we can see from following screenshot there are a lot of key bindings provided by tmux.

List Current Key Bindings
List Current Key Bindings

Start New Window

One of the most useful functionality of the tmux is operating multiple windows. Existing windows are listed in the green bar below. Creating new window will create new shell like a new tab in terminal emulators.

New Window
New Window

Move Next Window

While working with multiple windows navigation between windows can be done in different ways. One of the most common usage is switching next window with following key short cut.

Move Next Window
Move Next Window

After switching the asterisk which shows the current desktop will put new window afterward.

LEARN MORE  How To Cut Existing Network Connection In Linux?

Move Previous Window

This is similar to to moving next window. Just type following keyboard shortcut

Move Previous Window
Move Previous Window

Move Window With Number

Another useful navigation feature is using window number to navigate. Window numbers can be seen below of the terminal before the window name.

Rename Window

Normally tmux sets current running application name as window name. If we are using a lot of windows for multiple operations and we want to rename the window name.

Rename Window Name
Rename Window Name

Pane

Pane are used to multiplex single window. Using multiple commands in a single window is very useful and popular usage. Below we can see two horizontal pane. We will look how to create panes below.

Tmux Pane
Tmux Pane

Create New Vertical Pane

Current window can be divided in to two vertical pane with

Vertical Pane
Vertical Pane

After creating pane current working pane will change to new pane and active pane can be seen the line between panes. The lower part of the line is yellow which means left pane is active.

New Horizontal Pane

Horizontal pane can be created with

New Horizontal Pane
New Horizontal Pane

Move and Navigate Between Panes

To move between panes direction keys can be used like below.

Move Left Pane

Move Right Pane

Move Below Pane

Move Upper Pane

Show Pane Numbers

While working multiple pane it can be useful to show pane numbers. Pane numbers can be shown according to their location with command below. While showing pane number in the upper left corner of the pane the size is also shown.

LEARN MORE  How To Enable BitTorrent Ports In Linux Firewall?

Show Pane Numbers
Show Pane Numbers

Copy

One of the most important feature is copying and pasting text from terminal. Tmux provides a bit different method to copy paste. Normally console provided copy paste can be used but if source is multiline text it can be impossible to copy properly. Below is the steps to copy text.

Copy Mode

Copy Mode
Copy Mode

Set Start Point

We can move cursor to the start of the copy range in the copy mode and after that to set starting point following command is used.

Copy Mode
Copy Mode

Set End Point

Move cursor and we see can see the current selection is in orange color. To set end point and copy the contents to the buffer use following command.

Paste

Copied text will be put into the buffer. We can use these text wherever we want. We can also access this text in tmux from different windows.

Tmux Paste
Tmux Paste

Create Session

Creating a tmux session is just starting tmux. But we can also provide some parameters like name.

Create Session
Create Session

List Sessions

There may be more than one tmux sessions. This sessions can be listed with the following command

List Sessions
List Sessions

Detach Tmux

Existing session can be detached like below. This will not end the session thus this will only detach session from current shell and it will continue running in the background.

Detach Tmux
Detach Tmux

Reattach

Attaching session means reconnecting currently running session which is detached before.

Configuration File

There is to  path where configuration file resides. /etc/tmux.conf and ~/.tmux.conf

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-tmux-tutorial-command-examples/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.