![tmux在linux的使用](https://img-blog.csdnimg.cn/img_convert/591d48264b38d4b9f414e1ee4c46ec31.png)
tmux在linux的使用
![A stylized Linux terminal on a laptop with shell sessions in the background.](https://img-blog.csdnimg.cn/img_convert/293ac3c91f48caab014b6eeac971226a.png)
The Linux tmux
command is a terminal multiplexer, like screen
. Its advocates are many and vocal, so we decided to compare the two. Is tmux
really better, or is it just a case of preferring what you know?
Linux tmux
命令是终端多路复用器,如screen
。 它的拥护者很多,也很积极,因此我们决定将两者进行比较。 tmux
真的更好吗,还是只是更喜欢您所知道的?
tmux与屏幕 (tmux vs. screen)
Both the tmux
and GNU screen
commands are terminal multiplexers. They allow you to have multiple windows within a single terminal window, and to jump back and forth between them. A window can be divided into panes, each of which gives you an independent command line.
tmux
和GNU screen
命令都是终端多路复用器。 它们使您可以在一个终端窗口中拥有多个窗口,并在它们之间来回跳转。 窗口可以分为多个窗格,每个窗格都为您提供一个独立的命令行。
You can also detach a session and it becomes a headless entity running in the background—you can even close the terminal window that launched it. When you’re ready, you can open a new terminal window and reattach the still-running session. You can also do this over an SSH connection.
您还可以分离会话,它变成在后台运行的无头实体,甚至可以关闭启动该会话的终端窗口。 准备就绪后,您可以打开一个新的终端窗口并重新连接仍在运行的会话。 您也可以通过SSH连接执行此操作。
You can detach a session on one computer, go home, and log in to the remote computer. When reconnected, you can reattach the background session and use it interactively again.
您可以在一台计算机上分离会话,回家然后登录到远程计算机。 重新连接后,您可以重新连接后台会话,然后再次以交互方式使用它。
屏幕命令是什么? (What’s the screen Command?)
The screen
command is also a terminal multiplexer, and it’s packed with options. For the lowdown on everything you can do with it, check out our in-depth article.
screen
命令也是终端多路复用器,并且带有选项。 有关您可以使用它的所有功能的最低要求,请查看我们的深入文章。
This time, we’re going to concentrate on tmux
. As we go along, we’ll mention how screen
handles the same feature or function.
这次,我们将专注于tmux
。 在进行过程中,我们将提到screen
如何处理相同的功能。
Only one thing annoyed us about screen
. We’ll cover that when we get to it, and see if tmux
fares any better.
关于screen
只有一件事使我们恼火。 我们将在开始时进行介绍,并查看tmux
票价是否更好。
安装tmux (Installing tmux)
While screen
is generally installed by default on popular Linux distributions, tmux
isn’t. To install tmux
on Ubuntu, type the following:
虽然通常在流行Linux发行版中默认安装screen
,但tmux
却没有。 要在Ubuntu上安装tmux
,请输入以下命令:
sudo apt-get install tmux
![sudo apt-get install tmux in a terminal window.](https://img-blog.csdnimg.cn/img_convert/c596cd429f602cc41b26f63619e88f39.png)
On Manjaro you can use pacman
:
在Manjaro上,您可以使用pacman
:
sudo pacman -Sy tmux
![sudo pacman -Sy tmux in a terminal window.](https://img-blog.csdnimg.cn/img_convert/a0c46ce105ee98bd52e132da578f86a3.png)
On Fedora 31, tmux
is already installed.
在Fedora 31上,已经安装了tmux
。
开始一个tmux会话 (Starting a tmux Session)
To start tmux
, just type it and hit Enter:
要启动tmux
,只需键入它并按Enter:
tmux
![tmux in a terminal window.](https://img-blog.csdnimg.cn/img_convert/fe4d5edbb14e85560fce5e1f95e4fb08.png)
The terminal window will show a st