In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use Tmux to improve the efficiency in the terminal environment". In the daily operation, I believe many people have doubts about how to use Tmux to improve the efficiency in the terminal environment. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to use Tmux to improve the efficiency in the terminal environment". Next, please follow the editor to study!
The invention of the mouse is a great innovation, it makes the computer closer to ordinary people. But from the point of view of programmers and system administrators, when using a computer to work, once the hand is away from the keyboard, it will be a little distracted.
As a system administrator, I do a lot of work in a terminal environment. Opening a lot of tabs and switching windows between multiple terminals slows me down. Especially when there is something wrong with my server, I can't waste any time!
Tmux is one of the necessary tools for my daily work. I can build a complex development environment with Tmux, and I can also make SSH remote connections on the side. I can open a lot of windows, split it into many panels, take over and detach sessions, and so on. Once you have mastered Tmux, you can drop the mouse (just a joke: d).
Tmux (short for "Terminal Multiplexer") allows us to open many terminals under the flexible layout of a single screen, and we can use them collaboratively. For example, in one panel, we use Vim to modify some configuration files, in another panel, we use irssi chat, and in the rest of the panel, we can track some logs. Then we can open a new window to upgrade the system and a new window to make ssh connections to the server. Navigating between these window panels is as easy as creating them. It is highly configurable and customizable, making it an extension of your heart
Install Tmux under Linux/OSX
You can install it by compiling the software source or through the system package manager. I recommend using the package manager, which is faster and easier than compiling
OSX:# sudo brew install tmux# sudo port install tmuxDebian/Ubuntu:# sudo apt-get install tmuxRHEL/CentOS/Fedora (RHEL/CentOS requires EPEL repo): $sudo yum install tmuxArchlinux:$ sudo pacman-S tmux works with different sessions
The way to use Tmux is to use conversations so that you can organize tasks and applications into different sessions in the way you want. If you want to change a conversation, you don't have to stop or kill any work in the session. Let's see how this works.
Let's start a session called "session" and run the top command
$tmux new-s new session$ top
Then type CTRL-b d to detach from this session. To reconnect the session, type:
$tmux attach-session-t session
Then you will see that the top operation is still running on the reconnected session.
Some commands for managing sessions:
$tmux list-session$ tmux new-session $tmux attach-session-t $tmux rename-session-t $tmux choose-session-t $tmux kill-session-t works with different windows
In many cases, you need to run multiple commands and perform multiple tasks in a session. We can organize them in multiple windows of a session. In modern GUI terminals (such as iTerm or Konsole), a window is treated as a tab. After configuring our default environment in the session, we can create many of the windows we need in a session. A window is like an application running in a session. It persists when we leave the current session. Let's look at an example:
$tmux new-s my_session
Press CTRL-b c
This will create a new window, and then the screen cursor will move towards it. Now you can run your new application in a new window. You can change the name of your current window. In the current example, I'm running the top program, so top is the name of the window.
If you want to rename, just press:
CTRL-b
The status bar will change and you will be able to rename the current window
Once we have created multiple windows in a session, we need a way to move between them. Windows are organized like arrays, marking each window with a number starting at 0, and want to quickly jump to the rest of the window:
CTRL-b
If we name the windows, we can find them using the following command:
CTRL-b f
You can also list all windows:
CTRL-b w
Switch to different windows in order:
CTRL-b n (to next window) CTRL-b p (to previous window)
To leave a window, type exit or:
CTRL-b &
You need to make sure before you close the window.
Divide the window into many panels
Sometimes you need to check the log files while you are working in the editor. It's really helpful to track logs while editing. Tmux allows us to divide the window into many panels. For example, we can create a console to monitor our server and build a complex development environment with an editor so that we can compile and debug at the same time.
Let's create another Tmux session and let it work as a panel. First of all, if we are in a session, we are detached from the Tmux session:
CTRL-b d
Start a new session called "panes":
$tmux new-s panes
You can split a window horizontally or vertically, and split input horizontally:
CRTL-b "
Now you have two panels, and now we split them vertically:
CRTL-b%
Two more have been added:
Move between them:
CTRL-b
Conclusion
I hope this tutorial will work for you. In addition, tools like Tmuxinator or Tmuxifier simplify the creation and loading of Tmux sessions, windows and panels, and you can easily configure Tmux. If you haven't used these, give it a try!
At this point, the study on "how to use Tmux to improve efficiency in the terminal environment" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.