{"id":3489,"date":"2025-08-18T06:38:03","date_gmt":"2025-08-18T06:38:03","guid":{"rendered":"https:\/\/kedar.nitty-witty.com\/blog\/?p=3489"},"modified":"2025-08-19T05:10:47","modified_gmt":"2025-08-19T05:10:47","slug":"how-to-use-tmux-a-cheat-sheet","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/how-to-use-tmux-a-cheat-sheet","title":{"rendered":"How to use tmux, a cheat sheet"},"content":{"rendered":"\n<p>I think we know that screen is officially old news and most modern Linux systems switched to tmux as the recommended multiplexer with RHEL 8. Recently I had a discussion amongst my DBA gang for tmux migration and decided to write this. If you\u2019re still using screen, now\u2019s the time to upgrade: tmux is fun! (I know I&#8217;m late in the party but better late than never)<\/p>\n\n\n\n<p>This tmux cheat sheet combins session management, logging, reloading config, and scrolling commands in a quick reference format. You can also configure the tmux commands identical to screen by config file (using Ctrl-a).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tmux Demo Session<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"tmux how tos - a quick guide and demo cheatsheet\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/Fjn74vK1xv4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tmux-cheat-sheet-quick-commands--config\">Tmux Session Management<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Action<\/th><th>Command \/ Shortcut<\/th><\/tr><\/thead><tbody><tr><td>Start new session<\/td><td><code>tmux new -s session_name<\/code><\/td><\/tr><tr><td>List sessions<\/td><td><code>tmux ls<\/code><\/td><\/tr><tr><td>Attach session<\/td><td><code>tmux attach -t session_name<\/code><br><code>tmux a<\/code> (last session)<\/td><\/tr><tr><td>Detach session<\/td><td><code>Ctrl + b<\/code> then <code>d<\/code><\/td><\/tr><tr><td>Kill session<\/td><td><code>tmux kill-session -t session_name<\/code><br>(or connect session and exit)<br><\/td><\/tr><tr><td>Attach a session<\/td><td>tmux attach-session -t session_name<\/td><\/tr><tr><td>Forcefully take-over a session<\/td><td>tmux attach-session -d -t session_name<\/td><\/tr><tr><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"logging\">Tmux Logging<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Action<\/th><th>Command<\/th><\/tr><\/thead><tbody><tr><td>Start logging current pane<\/td><td><code>tmux pipe-pane -o 'cat &gt;&gt; ~\/tmux.log'<\/code><\/td><\/tr><tr><td>Stop logging<\/td><td><code>tmux pipe-pane<\/code><\/td><\/tr><tr><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"reload-config\">Tmux Reload Config<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Action<\/th><th>Command \/ Shortcut<\/th><\/tr><\/thead><tbody><tr><td>Reload config<\/td><td><code>tmux source-file ~\/.tmux.conf<\/code> (from shell)<\/td><\/tr><tr><td>Reload config (inside tmux)<\/td><td><code>Ctrl + b<\/code> then <code>:<\/code> then <code>source-file ~\/.tmux.conf<\/code><\/td><\/tr><tr><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"scrolling--copy-mode\">Tmux Scrolling \/ Copy Mode<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Action<\/th><th>Command \/ Shortcut<\/th><\/tr><\/thead><tbody><tr><td>Enter copy\/scroll mode<\/td><td><code>Ctrl + b<\/code> then <code>[<\/code><\/td><\/tr><tr><td>Scroll up\/down<\/td><td>Arrow keys, <code>Page Up<\/code> \/ <code>Page Down<\/code><\/td><\/tr><tr><td>Exit copy mode<\/td><td><code>q<\/code> or <code>Esc<\/code><\/td><\/tr><tr><td>Enable mouse scrolling<\/td><td>Add &#8220;<code><em>set -g mouse on<\/em><\/code>&#8221; to <code>~\/.tmux.conf<\/code> and reload<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"key-bindings-default-prefix-ctrlb\">Tmux Key Bindings<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Action<\/th><th>Shortcut<\/th><\/tr><\/thead><tbody><tr><td>Detach session<\/td><td><code>Ctrl + b<\/code> then <code>d<\/code><\/td><\/tr><tr><td>List sessions<\/td><td><code>Ctrl + b<\/code> then <code>s<\/code><\/td><\/tr><tr><td>Rename session<\/td><td><code>Ctrl + b<\/code> then <code>$<\/code><\/td><\/tr><tr><td>New window<\/td><td><code>Ctrl + b<\/code> then <code>c<\/code><\/td><\/tr><tr><td>Split horizontally<\/td><td><code>Ctrl + b<\/code> then <code>\"<\/code><\/td><\/tr><tr><td>Split vertically<\/td><td><code>Ctrl + b<\/code> then <code>%<\/code><\/td><\/tr><tr><td>Navigate panes<\/td><td><code>Ctrl + b<\/code> then Arrow keys<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Configuration customization<\/h2>\n\n\n\n<p>You can customize using tmux.conf configuration file further with additional bind keys for your workflow!<\/p>\n\n\n\n<p>If you&#8217;re habituated to screen command you can change the default shortcut command from &#8220;Ctrl-b&#8221; to &#8220;Ctrl-a&#8221; using configuration. There&#8217;s more power in the configuration, have a look.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tmuxconf-cheat-sheet-key-settings--bindings\">tmux.conf: Key Settings &amp; Bindings<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Action<\/th><th>Command \/ Config Line<\/th><\/tr><\/thead><tbody><tr><td>Enable default pane logging to timestamped file<\/td><td>set-option -g default-command &#8216;tmux pipe-pane -o &#8220;cat &gt;&gt;~\/tmxlogs\/tmx-#{session_name}-\\`date +%Y%m%dT%H%M%S\\`.log&#8221;; \/bin\/bash -l&#8217;<\/td><\/tr><tr><td>Enable mouse support<\/td><td><code>set -g mouse on<\/code><\/td><\/tr><tr><td>Increase scrollback\/history buffer size<\/td><td><code>set -g history-limit 10000<\/code><\/td><\/tr><tr><td>Reload tmux config shortcut (prefix + r)<\/td><td><code>bind r source-file ~\/.tmux.conf \\; display-message \"Config reloaded!\"<\/code><\/td><\/tr><tr><td>Unbind default prefix key (Ctrl+b)<\/td><td><code>unbind C-b<\/code><\/td><\/tr><tr><td>Set prefix key to Ctrl+a (Screen style)<\/td><td><code>set-option -g prefix C-a<\/code><\/td><\/tr><tr><td>Reload config with prefix + Shift + R<\/td><td><code>bind-key R source-file ~\/.tmux.conf \\; display-message \"Config reloaded!\"<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"sample-tmuxconf\">Sample ~\/.tmux.conf<\/h6>\n\n\n\n<p>You can use the following configuration:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong># vim ~\/.tmux.conf<\/strong><br><br># Enable default logging <br>set-option -g default-command 'tmux pipe-pane -o \"cat &gt;&gt;~\/tmxlogs\/tmx-#{session_name}-\\`date +%Y%m%dT%H%M%S\\`.log\"; \/bin\/bash -l'<br><br><em># Enable mouse support for scrolling and pane selection<\/em><br>set -g mouse on  <br><br><em># Increase scrollback \/ log history buffer size<\/em><br>set -g history-limit 10000<br><br><em># Reload config shortcut<\/em> - Ctrl+b, R to reload config changes<br>bind r source-file ~\/.tmux.conf \\; display-message \"Config reloaded!\"<br><br><em># Scr<\/em>een compatible commands settings<br>unbind C-b                        <em># Unbind default prefix<\/em><br>set-option -g prefix C-a          <em># Set prefix to Ctrl+a<\/em> (same as screen)<br><\/pre>\n\n\n\n<p>To make use of configuration changes for the first time you need to run<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tmux source ~\/.tmux.conf<\/code><\/pre>\n\n\n\n<p>Once you have added &#8220;<em>Reload config shortcu<\/em>t&#8221; you just need to press: Ctrl-a, r to reload the changes.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"I think we know that screen is officially old news and most modern Linux systems switched to tmux as the recommended multiplexer with RHEL 8. Recently I had a discussion&hellip;\n","protected":false},"author":1,"featured_media":3494,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1130,6],"tags":[1121,1129,1125,1127,1117,1124,1128],"class_list":{"0":"post-3489","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-linux","8":"category-technical","9":"tag-tmux-conf","10":"tag-how-to-tmux","11":"tag-key-bindings","12":"tag-screen-to-tmux","13":"tag-terminal-multiplexer","14":"tag-tmux-cheat-sheet","15":"tag-tmux-configuration"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/3489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/comments?post=3489"}],"version-history":[{"count":16,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/3489\/revisions"}],"predecessor-version":[{"id":3506,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/3489\/revisions\/3506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media\/3494"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=3489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=3489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=3489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}