Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the tmux command in Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the tmux command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Linux common commands Tmux command is a terminal multiplexer that can replace GNU Screen. In other words, this means that you can start a Tmux session and then open multiple windows in that session. Each window occupies the entire screen and can be divided into rectangular panes.

Install Tmux you can easily install Tmux using the package manager of the distribution.

Install Tmux on Ubuntu and Debian

Sudo apt install tmux installs Tmux on CentOS and Fedora

Sudo yum install tmux installs Tmux on macOS

Brew install tmux start your first Tmux session to start your first Tmux session, just type tmux in the console:

Tmux this opens a new session, creates a new window, and starts a shell in that window.

After entering Tmux, you will see a status line at the bottom of the screen that displays information about the current session.

Now you can run the first Tmux command. For example, to get a list of all commands, enter:

Ctrl+b? Create a named Tmux session by default, Tmux sessions are named after numbers. Naming sessions is useful when you are running multiple Tmux sessions. To create a new naming session, tmux runs the command with the following parameters:

It's always a good idea for tmux new-s session_name to choose a descriptive session name.

Detach from a Tmux session you can detach from the Tmux session and return to the normal shell with the following command:

After detaching from the session, programs running in the Tmux session will continue to run.

To reconnect to a Tmux session, you first attach to the session, and you need to find the name of the session. To get a list of currently running sessions, enter:

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

0:1 windows (created Sat Sep 15 09:38:43 2018) [158x35] my_named_session: 1 windows (created Sat Sep 15 10:13:11 2018) [78x35] you can see from the output that there are two Tmux sessions running. The first one is named 0 and the second one is named.

My_named_session

.

For example, to attach to session 0, you can enter:

As you can see from the output, there are two running Tmux sessions. The first one is named 0 and the second one is named my_named_session.

For example, to attach to session 0, you can enter:

Tmux attach-session-t 0 uses Tmux Windows and panes. By default, when you start a new Tmux session, it creates a single window with a shell.

To create a new window with shell type, it will be assigned the first available number 0... 9 in the range of Ctrl+b c.

A list of all windows is displayed on the status line at the bottom of the screen.

Here are some of the most common commands for managing Tmux windows and panes:

Ctrl+b c create a new window (with shell)

Ctrl+b w Select a window from the list

Ctrl+b 0 switch to window 0 (by number)

Ctrl+b, renaming the current window

Ctrl+b% split the current pane horizontally into two panes

Ctrl+b splits the current pane vertically into two panes

Ctrl+b o go to the next pane

Ctrl+b; switch between the current pane and the previous pane

Ctrl+b x closes the current pane

When a custom Tmux starts Tmux, it reads its configuration parameters from whether a file exists in ~ / .tmux.conf.

This is a sample configuration of ~ / .tmux.conf with a custom status line and some other options:

# Improve colorsset-g default-terminal 'screen-256color'# Set scrollback buffer to 10000set-g history-limit 1000 Customize the status lineset-g status-fg greenset-g status-bg black

Tmux screenshot

The following are the most basic steps for getting started with Tmux:

At the command prompt, type tmux new-s my_session

Run the required program.

Detach from the session using the key sequence Ctrl-b+ d.

Reconnect to the Tmux session tmux attach-session-t my_session by typing.

The above is all the contents of the article "how to use tmux commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report