{"id":65073,"date":"2022-06-14T09:00:57","date_gmt":"2022-06-14T09:00:57","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=65073"},"modified":"2022-06-14T09:00:57","modified_gmt":"2022-06-14T09:00:57","slug":"share-your-linux-terminal-with-tmate","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=65073","title":{"rendered":"Share your Linux terminal with tmate"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">Share your Linux terminal with tmate<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/sumantro\" class=\"username\">Sumantro Mukherjee<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Tue, 06\/14\/2022 &#8211; 03:00<\/span><\/p>\n<div data-drupal-selector=\"rate-node-70061\" class=\"rate-widget-thumbs-up\" title=\"Register or Login to like.\">\n<div class=\"rate-thumbs-up-btn-up vote-pending\">1 reader likes this<\/div>\n<div class=\"rate-score\">1 reader likes this<\/div>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>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&#8217;ve ever used a <a href=\"https:\/\/opensource.com\/article\/21\/5\/linux-terminal-multiplexer\">terminal multiplexer<\/a> like <a href=\"https:\/\/opensource.com\/downloads\/tmux-cheat-sheet\">tmux<\/a> or <a href=\"https:\/\/opensource.com\/article\/17\/3\/introduction-gnu-screen\">GNU Screen<\/a>, you might think that that&#8217;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\u2014which they can readily do because I use <a href=\"https:\/\/tmate.io\/\" target=\"_blank\" rel=\"noopener\">tmate<\/a>.<\/p>\n<h2>Linux terminal sharing with tmate<\/h2>\n<p>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&#8217;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 <a href=\"https:\/\/opensource.com\/article\/22\/1\/record-your-terminal-session-asciinema\">Asciinema<\/a> or <a href=\"https:\/\/www.redhat.com\/sysadmin\/record-terminal-script-scriptreplay\" target=\"_blank\" rel=\"noopener\">script and scriptreplay<\/a>.<\/p>\n<p>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.<\/p>\n<p>I use read-only mode when I&#8217;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.<\/p>\n<h2>Linux tmate in action<\/h2>\n<p>On Linux, you can install tmate with your package manager. For instance, on Fedora:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> dnf <span class=\"kw2\">install<\/span> tmate<\/code><\/span><\/pre>\n<p>On Debian and similar distributions:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> tmate<\/code><\/span><\/pre>\n<p>On macOS, you can install it using <a href=\"https:\/\/opensource.com\/article\/20\/6\/homebrew-mac\">Homebrew<\/a> or <a href=\"https:\/\/opensource.com\/article\/20\/11\/macports\">MacPorts<\/a>. If you need instructions for other Linux distributions, refer to the <a href=\"https:\/\/tmate.io\/\" target=\"_blank\" rel=\"noopener\">install<\/a> guide.<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/install2520tmate_0.png\" width=\"675\" height=\"354\" alt=\"Screenshot of terminal showing the options for tmate sharing: web session (regular and read-only) and ssh session (regular and read-only)\" loading=\"lazy\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Sumantro Mukherjee, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p>Once installed, start tmate:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>tmate<\/code><\/span><\/pre>\n<p>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.<\/p>\n<p>Here&#8217;s what a web session looks like:<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/tmate2520web2520session.png\" width=\"675\" height=\"359\" alt=\"Screenshot showing tmate terminal window and 2 versions of sharing sessions demonstrating the same code\" loading=\"lazy\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Sumantro Mukherjee, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p>Tmate&#8217;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.<\/p>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">More Linux resources<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/linux-commands-cheat-sheet\/?intcmp=70160000000h1jYAAQ\">Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/advanced-linux-commands\/?intcmp=70160000000h1jYAAQ\">Advanced Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/rh024-red-hat-linux-technical-overview?intcmp=70160000000h1jYAAQ\">Free online course: RHEL technical overview<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-networking?intcmp=70160000000h1jYAAQ\">Linux networking cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-selinux?intcmp=70160000000h1jYAAQ\">SELinux cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/linux-common-commands-cheat-sheet?intcmp=70160000000h1jYAAQ\">Linux common commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/resources\/what-are-linux-containers?intcmp=70160000000h1jYAAQ\">What are Linux containers?<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux?intcmp=70160000000h1jYAAQ\">Our latest Linux articles<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h2>Keeping a session alive<\/h2>\n<p>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.<\/p>\n<p>And of course, that&#8217;s exactly what tmate can do. If you&#8217;ve ever used tmux, this is probably pretty familiar.<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>tmate <span class=\"re5\">-F<\/span> <span class=\"re5\">-n<\/span> web new-session <span class=\"kw2\">vi<\/span>\u00a0 console<\/code><\/span><\/pre>\n<p>This command opens up <code>new-session<\/code> in Vi, and the <code>-F <\/code>option ensures that the session re-spawns even when closed.<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/tmate2520keeping2520session2520alive.png\" width=\"675\" height=\"350\" alt=\"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)\" loading=\"lazy\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Sumantro Mukherjee, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<h2>Social multiplexing<\/h2>\n<p>Tmate gives you the freedom of tmux or GNU Screen plus the ability to share your sessions with others. It&#8217;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&#8217;s open source, so give it a try!<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>Tmate expands your options for session sharing with the Linux terminal.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/terminal_command_linux_desktop_code.jpg\" width=\"520\" height=\"292\" alt=\"Terminal command prompt on orange background\" title=\"Terminal command prompt on orange background\" loading=\"lazy\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p><a href=\"https:\/\/pixabay.com\/en\/users\/iradaturrahmat-3964359\/\" target=\"_blank\" rel=\"noopener\">iradaturrahmat\u00a0<\/a>via <a href=\"https:\/\/pixabay.com\/en\/ubuntu-computer-program-interface-3145957\/\" target=\"_blank\" rel=\"noopener\">Pixabay<\/a>, CC0<\/p>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux\" hreflang=\"en\">Linux<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-listicles field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/article\/19\/6\/tmux-terminal-joy\" hreflang=\"und\">How tmux sparks joy in your Linux terminal<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/cc-by-sa--15.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Share your Linux terminal with tmate Sumantro Mukherjee Tue, 06\/14\/2022 &#8211; 03:00 1 reader likes this 1 reader likes this 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&#8217;ve ever used a terminal multiplexer like tmux [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":65074,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-65073","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/65073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65073"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/65073\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/65074"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}