Linux uses Tmux to improve the efficiency of terminal operations.

  

In Linux terminal operations, sometimes it is necessary to operate on multiple terminals, and switching between windows requires a lot of time. So what methods can speed up the operation of the terminal? In fact, using Tmux will solve this problem perfectly. The following small series will introduce you to the way Linux uses Tmux to improve the efficiency of terminal operation.

Tmux is one of my daily work necessary tools. I can build a complex development environment with Tmux, and I can also connect SSH remotely. I can open a lot of windows, split it into many panels, take over and separate sessions, and more. After mastering Tmux, you can throw away the mouse.

Tmux ("Terminal Multiplexer") can allow 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 to chat, while in the remaining panels, we can track some logs. Then, we can open a new window to upgrade the system, and then open a new window to the server's ssh connection. It's as simple as browsing between these window panels to switch between them. It's highly configurable and customizable, making it an extension of your mind

Installing Tmux under Linux/OSX (see the steps for installing the Tmux software from the System Home CentOS).

You can install it by compiling the software source or by using 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 tmux

Debian/Ubuntu:

# sudo apt-get install tmux

RHEL/CentOS/Fedora(RHEL/CentOS requires EPEL repo):

$ sudo yum install tmux

Archlinux:

$ sudo pacman -S tmux

Working with different sessions

The best way to use Tmux is to use a session, so you can organize tasks and applications into different sessions the way you want. If you want to change a session, there is no need 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

Enter CTRL-b d to detach from this session. To reconnect to this session, enter:

$ tmux attach-session -t session

After that you will see that the top operation is still running again. Connected on the session.

Some commands for managing sessions:

$ tmux list-session

$ tmux new-session "session name"

$ tmux attach-session - t "session name"

$ tmux rename-session -t "session name"

$ tmux choose-session -t "session name"

$ tmux kill-session -t "session name"

Working with different windows

In many cases, you need to run multiple commands in a single session to perform multiple tasks. 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 label. After configuring our default environment in the session, we are able to create many of the windows we need in one session. A window is like an application running in a session. When we are out of the current session, it is still going on. Let's look at an example:

$ tmux new-s my_session
Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved