Merge pull request #26094 from geekpi/translating

translated
This commit is contained in:
geekpi 2022-06-17 08:28:36 +08:00 committed by GitHub
commit b42ba2e5ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 107 additions and 107 deletions

View File

@ -1,107 +0,0 @@
[#]: subject: "Share your Linux terminal with tmate"
[#]: via: "https://opensource.com/article/22/6/share-linux-terminal-tmate"
[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Share your Linux terminal with tmate
======
Tmate expands your options for session sharing with the Linux terminal.
![Terminal command prompt on orange background][1]
Image by: [iradaturrahmat][2]via [Pixabay][3], CC0
As a member of the Fedora Linux QA team, I sometimes find myself executing a bunch of commands that I want to broadcast to other developers. If you've ever used a [terminal multiplexer][4] like [tmux][5] or [GNU Screen][6], you might think that that's a relatively easy task. But not all of the people I want to see my demonstration are connecting to my terminal session from a laptop or desktop. Some might have casually opened it from their phone browser—which they can readily do because I use [tmate][7].
### Linux terminal sharing with tmate
Watching someone else work in a Linux terminal is very educational. You can learn new commands, new workflows, or new ways to debug and automate. But it can be difficult to capture what you're seeing so you can try it yourself later. You might resort to taking screenshots or a screen recording of a shared terminal session so you can type out each command later. The only other option is for the person demonstrating the commands to record the session using a tool like [Asciinema][8] or [script and scriptreplay][9].
But with tmate, a user can share a terminal either in read-only mode or over SSH. Both the SSH and the read-only session can be accessed through a terminal or as an HTML webpage.
I use read-only mode when I'm onboarding people for the Fedora QA team because I need to run commands and show the output, but with tmate, folks can keep notes by copying and pasting from their browser to a text editor.
### Linux tmate in action
On Linux, you can install tmate with your package manager. For instance, on Fedora:
```
$ sudo dnf install tmate
```
On Debian and similar distributions:
```
$ sudo apt install tmate
```
On macOS, you can install it using [Homebrew][10] or [MacPorts][11]. If you need instructions for other Linux distributions, refer to the [install][12] guide.
![Screenshot of terminal showing the options for tmate sharing: web session (regular and read-only) and ssh session (regular and read-only)][13]
Once installed, start tmate:
```
$ tmate
```
When tmate launches, links are generated to provide access to your terminal session over HTTP and SSH. Each protocol features a read-only option as well as a reverse SSH session.
Here's what a web session looks like:
![Screenshot showing tmate terminal window and 2 versions of sharing sessions demonstrating the same code][14]
Tmate's web console is HTML5, so, as a result, a user can copy the entire screen and paste it into a terminal to run the same commands.
### Keeping a session alive
You may wonder what happens if you accidentally close your terminal. You may also wonder about sharing your terminal with a different console application. After all, tmate is a multiplexer, so it should be able to keep sessions alive, detach and re-attach to a session, and so on.
And of course, that's exactly what tmate can do. If you've ever used tmux, this is probably pretty familiar.
```
$ tmate -F -n web new-session vi  console
```
This command opens up `new-session` in Vi, and the `-F` option ensures that the session re-spawns even when closed.
![A screenshot of the terminal showing the output after using the new-session and -F options: connection information for either a web session (regular or read-only) or ssh session (regular or read-only)][15]
### Social multiplexing
Tmate gives you the freedom of tmux or GNU Screen plus the ability to share your sessions with others. It's a valuable tool for teaching other users how to use a terminal, demonstrating the function of a new command, or debugging unexpected behavior. It's open source, so give it a try!
Image by: (Sumantro Mukherjee, CC BY-SA 4.0)
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/6/share-linux-terminal-tmate
作者:[Sumantro Mukherjee][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/sumantro
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/terminal_command_linux_desktop_code.jpg
[2]: https://pixabay.com/en/users/iradaturrahmat-3964359/
[3]: https://pixabay.com/en/ubuntu-computer-program-interface-3145957/
[4]: https://opensource.com/article/21/5/linux-terminal-multiplexer
[5]: https://opensource.com/downloads/tmux-cheat-sheet
[6]: https://opensource.com/article/17/3/introduction-gnu-screen
[7]: https://tmate.io/
[8]: https://opensource.com/article/22/1/record-your-terminal-session-asciinema
[9]: https://www.redhat.com/sysadmin/record-terminal-script-scriptreplay
[10]: https://opensource.com/article/20/6/homebrew-mac
[11]: https://opensource.com/article/20/11/macports
[12]: https://tmate.io/
[13]: https://opensource.com/sites/default/files/2022-06/install%20tmate_0.png
[14]: https://opensource.com/sites/default/files/2022-06/tmate%20web%20session.png
[15]: https://opensource.com/sites/default/files/2022-06/tmate%20keeping%20session%20alive.png

View File

@ -0,0 +1,107 @@
[#]: subject: "Share your Linux terminal with tmate"
[#]: via: "https://opensource.com/article/22/6/share-linux-terminal-tmate"
[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
用 tmate 分享你的 Linux 终端
======
Tmate 扩展了你与 Linux 终端共享会话的选项。
![Terminal command prompt on orange background][1]
图片提供: [iradaturrahmat][2] 通过 [Pixabay][3]CC0
作为 Fedora Linux QA 团队的一员,我有时会发现自己执行了一堆我想广播给其他开发者的命令。如果你曾经使用过像 [tmux][5] 或 [GNU Screen][6] 这样的[终端复用器][4],你可能会认为这是一个相对容易的任务。但并不是所有我想看我的演示的人都是从笔记本电脑或台式机连接到我的终端会话的。有些人可能是随便从他们的手机浏览器中打开的,他们可以很容易地做到这一点,因为我使用了[tmate][7]。
### 使用 tmate 共享 Linux终端
看别人在 Linux 终端工作是非常有教育意义的。你可以学到新的命令,新的工作流程,或者新的调试和自动化的方法。但要捕捉到你所看到的东西,以便你以后可以自己尝试,这可能很困难。你可能会诉诸于截图或共享终端会话的屏幕记录,这样你就可以在以后打出每个命令。唯一的选择是由演示命令的人使用 [Asciinema][8] 或 [script 和 scriptreplay][9] 等工具来记录会话。
但是通过 tmate用户可以在只读模式下或通过 SSH 共享一个终端。SSH 和只读会话都可以通过终端或以 HTML 网页的形式访问。
当我为 Fedora QA 团队培训人员时,我使用只读模式,因为我需要运行命令并显示输出,但有了 tmate人们可以通过从他们的浏览器复制和粘贴到文本编辑器来保持笔记。
### Linux tmate 上手
在 Linux 上,你可以用你的包管理器安装 tmate。例如在 Fedora 上:
```
$ sudo dnf install tmate
```
在 Debian 和类似的发行版上:
```
$ sudo apt install tmate
```
在 macOS 上,你可以用 [Homebrew][10] 或 [MacPorts][11] 安装它。如果你需要其他 Linux 发行版的说明,请参考[安装][12]指南。
![Screenshot of terminal showing the options for tmate sharing: web session (regular and read-only) and ssh session (regular and read-only)][13]
安装后,启动 tmate
```
$ tmate
```
当 tmate 启动时,会产生链接,通过 HTTP 和 SSH 提供对终端会话的访问。每个协议都有一个只读选项以及一个反向的 SSH 会话。
下面是一个网络会话的样子:
![Screenshot showing tmate terminal window and 2 versions of sharing sessions demonstrating the same code][14]
Tmate 的网络控制台是 HTML5 的,因此,用户可以复制整个屏幕并粘贴到终端来运行相同的命令。
### 保持会话活跃
你可能想知道如果你不小心关闭了你的终端会发生什么。你也可能想知道如何与不同的控制台应用共享你的终端。毕竟tmate 是一个多路复用器,所以它应该能够保持会话的活力,脱离并重新连接到一个会话,等等。
当然,这正是 tmate 所能做到的。如果你曾经使用过 tmux这可能是相当熟悉的。
```
$ tmate -F -n web new-session vi console
```
这个命令在 Vi 中打开了 `new-session``-F` 选项确保会话在关闭时也能重新产生。
![A screenshot of the terminal showing the output after using the new-session and -F options: connection information for either a web session (regular or read-only) or ssh session (regular or read-only)][15]
### 社交复用
Tmate 给你带来了 tmux 或 GNU Screen 的自由,以及与他人共享会话的能力。对于教其他用户如何使用终端,演示一个新命令的功能,或调试意外的行为,这是一个有价值的工具。它是开源的,所以请试一试!
图片提供Sumantro MukherjeeCC BY-SA 4.0
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/6/share-linux-terminal-tmate
作者:[Sumantro Mukherjee][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/sumantro
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/terminal_command_linux_desktop_code.jpg
[2]: https://pixabay.com/en/users/iradaturrahmat-3964359/
[3]: https://pixabay.com/en/ubuntu-computer-program-interface-3145957/
[4]: https://opensource.com/article/21/5/linux-terminal-multiplexer
[5]: https://opensource.com/downloads/tmux-cheat-sheet
[6]: https://opensource.com/article/17/3/introduction-gnu-screen
[7]: https://tmate.io/
[8]: https://opensource.com/article/22/1/record-your-terminal-session-asciinema
[9]: https://www.redhat.com/sysadmin/record-terminal-script-scriptreplay
[10]: https://opensource.com/article/20/6/homebrew-mac
[11]: https://opensource.com/article/20/11/macports
[12]: https://tmate.io/
[13]: https://opensource.com/sites/default/files/2022-06/install%20tmate_0.png
[14]: https://opensource.com/sites/default/files/2022-06/tmate%20web%20session.png
[15]: https://opensource.com/sites/default/files/2022-06/tmate%20keeping%20session%20alive.png