In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how Linux installs and uses the terminal multiplexer tmux related knowledge points, the content is detailed, the logic is clear, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.
Tmux is a tool that allows people to operate multiple sessions through one window. For students who often operate the Linux system, it is definitely a sharp tool to improve work efficiency.
Install and start tmux
The name of a tmux application comes from a terminal (terminal) multiplexer (muxer) or a multiplexer (multiplexer). In other words, it can divide your single-terminal session into multiple sessions. It manages windows and panes:
A window is a single view-that is, the various things displayed in the terminal. The pane is part of the view, which is usually a terminal session.
Before you start, please install the tmux application on the system. You need to set up sudo permissions for your user account or use the root account.
Sudo dnf-y install tmux [Fedora 22] sudo yum-y install tmux [Centos or RHEL] sudo apt-get-y install tmux [ubuntu]
Run the tmux program:
Tmux status bar
First of all, nothing seems to happen, except for the status bar that appears at the bottom of the terminal: the bottom bar shows:
[0]-this is the first session created by the tmux server. The number starts at 0. The tmux server tracks all sessions to see if they are alive. 0Rule testusername scarlettRose ~-Information about the first window of the session. The number starts at 0. This means that the terminals in the active pane of the window are owned by the testuser user in the hostname scarlett. The current directory is ~ (home directory). *-shows that you are currently in this window. "scarlett.internal.fri"-the hostname of the tmux server you are using. "in addition, the date and time on that particular host are displayed."
As you add more windows and panes to the session, the information bar will change.
Basic knowledge of tmux
Stretch your terminal window to the maximum. Now let's try some simple commands to create more panes. By default, all commands start with Ctrl+b.
Tap Ctrl+b, "split the current single pane horizontally. There are now two command line panes in the window, one at the top and one at the bottom. Note that the new pane at the bottom is the active pane. Click Ctrl+b to split the current single pane vertically. Now you have three command line panes in your window, and the lower right corner is the active pane.
Notice the highlighted border around the current pane. To browse all the panes:
Click Ctrl+b, then click the arrow key to tap Ctrl+b, Q, and the number will appear briefly on the pane. In the meantime, you can browse the corresponding numbers on the pane you want to browse.
Now, try running different commands using different panes. For example, the following:
Use the ls command to display the contents of the directory in the top pane. Use the vi command in the lower left pane to edit a text file. Run the top command in the lower right pane to monitor the system process.
The screen will be displayed as follows:
So far, only one window with multiple panes has been used in this example, and you can also run multiple windows in a session.
To create a new window, click Ctrl+b, c. Notice that the status bar shows that there are two windows currently running. (keen readers will see the screenshot above. To move to the previous window, click Ctrl+b, p. To move to the next window, click Ctrl+b, n. To move to a specific window immediately, click Ctrl+b and follow the window number.
If you want to know how to close panes, just use exit, logout, or Ctrl+d to exit a specific command line shell, and once you close all the panes in the window, the window will disappear.
Detach and attach
One of the most powerful features of tmux is the ability to detach and reattach to a session. When you leave, you can leave your windows and panes to run independently. In addition, you can even log out of the system completely. You can then log in to the same system, reattach to the tmux session, and view all windows and panes when you leave. The command you run remains running when you leave it.
To break away from a conversation, please Ctrl+b, d. Then the session disappears and you return to a standard single shell. If you want to reattach to the session, use the following command:
Tmux attach-session
This function is as useful as a lifeguard when the network you connect to the host is unstable. If the connection fails, all processes in the session continue to run. As long as the connection is restored, you can return to normal as if nothing had happened.
If these features are not enough, you can run multiple sessions in the top-level windows and panes of each session. You can list these windows and panes and append them to the correct session by number or name:
Tmux list-sessions above is all the content of the article "how to install and use the terminal multiplexer tmux in Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.