加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

使用 tmate 分享你的 Linux 终端

发布时间:2022-06-30 00:01:19 所属栏目:Linux 来源:互联网
导读:作为 Fedora Linux QA 团队的一员,我有时想将自己执行的一堆命令广而告之给其他开发者。如果你曾经使用过像 tmux 或 GNU Screen 这样的 终端复用器,你可能会认为这是一个挺轻松的任务。不是所有看我的示范的人都是从笔记本电脑或台式机连接到我的终端会
  作为 Fedora Linux QA 团队的一员,我有时想将自己执行的一堆命令广而告之给其他开发者。如果你曾经使用过像 tmux 或 GNU Screen 这样的 终端复用器,你可能会认为这是一个挺轻松的任务。不是所有看我的示范的人都是从笔记本电脑或台式机连接到我的终端会话的,有些人可能是随手在他们的手机浏览器中打开的,因为我使用了 tmate,所以他们可以很容易地做到这一点。

  Linux tmate 上手
  在 Linux 上,你可以用你的包管理器安装 ​​tmate​​。例如,在 Fedora 上:
 
  复制
      $ sudo dnf install tmate
  1.
  在 Debian 和类似的发行版上:
 
  复制
      $ sudo apt install tmate
  1.
  在 macOS 上,你可以用 Homebrew 或 MacPorts 安装它。如果你需要其他 Linux 发行版的说明,请参考 ​​安装​​ 指南。
 
  Screenshot of terminal showing the options for tmate sharing: web session (regular and read-only) and ssh session (regular and read-only)
 
  Screenshot  of terminal showing the options for tmate sharing: web session (regular and read-only) and ssh session (regular and read-only)
 
  安装后,启动 ​​tmate​​:
 
  当 ​​tmate​​ 启动时,会生成链接,通过 HTTP 和 SSH 提供对终端会话的访问。每个协议都有一个只读方式,以及一个反向的 SSH 会话。
 
  下面是一个网络会话的样子:
 
  Screenshot showing tmate terminal window and 2 versions of sharing sessions demonstrating the same code
 
  Screenshot showing tmate terminal window and 2 versions of sharing sessions demonstrating the same code
 
  ​​tmate​​ 的网络控制台是 HTML5 的,因此,用户可以复制整个屏幕并粘贴到终端来运行相同的命令。
 
  保持会话
  你可能想知道如果你不小心关闭了你的终端会发生什么。你也可能想知道如何与不同的控制台应用共享你的终端。毕竟,​​tmate​​ 是一个多路复用器,所以它应该能够保持会话,脱离并重新连接到一个会话,等等。
 
  当然,这正是 ​​tmate​​​ 所能做到的。如果你曾经使用过 ​​tmux​​,这可能是相当熟悉的。
 
  复制
      $ tmate -F -n web new-session vi console
  1.
  这个命令在 ​​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)

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读