{"id":15836,"date":"2019-03-06T11:53:20","date_gmt":"2019-03-06T11:53:20","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15836"},"modified":"2026-03-10T09:30:45","modified_gmt":"2026-03-10T09:30:45","slug":"how-to-use-tmux","status":"publish","type":"post","link":"\/ca\/tutorials\/how-to-use-tmux","title":{"rendered":"How to use tmux for terminal multitasking"},"content":{"rendered":"<p>A terminal multiplexer, or tmux, is <strong>a command-line tool that lets you manage multiple terminal sessions in a single window<\/strong>. With tmux, you can split panes, create multiple windows, and keep sessions active in the background.<\/p><p>The primary benefit of tmux is persistence. If your SSH connection drops or you accidentally close your terminal emulator, the processes running inside tmux continue on the server. You can reconnect and resume work exactly where you left off.<\/p><p>The essential steps to mastering tmux include:<\/p><ul class=\"wp-block-list\">\n<li><strong>Installation<\/strong>. Set up tmux on your Linux system and verify the installed version.<\/li>\n\n\n\n<li><strong>Session management<\/strong>. Start named sessions, detach without stopping processes, and reattach later.<\/li>\n\n\n\n<li><strong>Window organization<\/strong>. Create, rename, and navigate multiple windows to keep tasks separate.<\/li>\n\n\n\n<li><strong>Pane control<\/strong>. Split a single window into multiple visible sections for simultaneous monitoring.<\/li>\n\n\n\n<li><strong>Customization<\/strong>. Modify keybindings and behavior through the <strong>.tmux.conf<\/strong> file.<\/li>\n<\/ul><p>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-use-tmux\"><strong>How to use tmux<\/strong><\/h2><p>To use tmux, <strong>first install the utility on your server, then start a session using the tmux command<\/strong>.<\/p><p>Once inside a session, you use a specific prefix key (<strong>Ctrl + B<\/strong> by default) combined with other keys to perform actions such as splitting the screen or creating new windows.<\/p><p>When you finish working but want to keep processes running, you detach from the session. tmux keeps it active in the background until you attach to it again later.<\/p><h3 class=\"wp-block-heading\"><strong>Install tmux<\/strong><\/h3><p>Most Linux distributions do not include tmux by default, so you usually need to install it manually. You need superuser or root privileges to install packages.<\/p><ol class=\"wp-block-list\">\n<li>Log in to your remote system using an SSH client such as <a href=\"\/ca\/tutorials\/how-to-use-putty-ssh\">PuTTY<\/a> or your local terminal. Hostinger VPS users can find their login credentials in the <strong>VPS Overview<\/strong> section of hPanel.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f7001a426\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/hpanel-vps-overview-root-access-highlighted-1-1024x458.png\" alt=\"hPanel VPS overview highlighting root access login credentials\" class=\"wp-image-137633\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"2\" class=\"wp-block-list\">\n<li>Before installing tmux, update your system&rsquo;s package repository to make sure you download the latest stable version. Run one of the following commands, depending on your distribution:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update        # Debian and Ubuntu<\/pre><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf makecache     # RHEL, CentOS, and Fedora<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Once the update completes, run the appropriate installation command:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install tmux  # Debian and Ubuntu<\/pre><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum install tmux  # RHEL and CentOS<\/pre><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf install tmux  # Fedora<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>After the installation finishes, confirm that tmux is installed by checking the version:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux -V<\/pre><p>If the terminal returns a version number, such as tmux 3.4 or later, the installation succeeded. If you see a &ldquo;command not found&rdquo; error, verify your PATH or try reinstalling tmux.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f7001c84c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-v-1-1024x183.png\" alt=\"Terminal output showing the tmux version command result\" class=\"wp-image-137634\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ca\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\"><strong>Start a new session<\/strong><\/h3><p>You can start a tmux session by typing <strong>tmux<\/strong> in your main terminal window. By default, tmux assigns each session a numeric ID starting at <strong>0<\/strong>.<\/p><p>This approach works for quick tasks but becomes hard to manage when you run multiple sessions at the same time.<\/p><p>We recommend starting each session with a custom name. When you run <strong>tmux ls<\/strong> to list sessions, numeric IDs such as <strong>0<\/strong>, <strong>1<\/strong>, or <strong>2<\/strong> provide little context. Descriptive names like <strong>backend-deployment<\/strong> or <strong>server-logs<\/strong> make each session&rsquo;s purpose clear at a glance.<\/p><p>To start a named session, use the <strong>-s<\/strong> flag followed by your chosen name:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux new -s session-name<\/pre><p>After you run this command, tmux clears the terminal and displays a status bar at the bottom of the screen. By default, the bar appears green, but you can customize it.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f7001fb45\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-session-1024x602.png\" alt=\"Active tmux session displayed inside a terminal window\" class=\"wp-image-137635\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>The status bar confirms that you are inside a tmux session. It shows the current shell (usually <strong>bash<\/strong> or <strong>zsh<\/strong>), the session name, and the current time.<\/p><h3 class=\"wp-block-heading\"><strong>Detach and attach sessions<\/strong><\/h3><p>One of tmux&rsquo;s most important features is the ability to detach from a session. Detaching sends the session to the background and keeps all running programs active, while returning you to the main shell prompt.<\/p><p>This feature helps when you run long processes, such as database migrations, and need to disconnect your SSH client, or when your internet connection is unstable.<\/p><p>If the connection drops unexpectedly, tmux detaches the session instead of terminating it.<\/p><p>To detach from a session, press the prefix key <strong>Ctrl + B<\/strong>, release both keys, then immediately press <strong>D<\/strong>. The terminal will display a <strong>[detached]<\/strong> message.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f7002165c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-detached-highlighted-1024x103.png\" alt=\"Terminal showing tmux session detached status highlighted\" class=\"wp-image-137636\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>To resume work, reattach to the session. If only one session is running, use:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux attach<\/pre><p>If multiple sessions are active, specify the target session with the <strong>-t<\/strong> flag:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux attach -t session-name<\/pre><p>You can also use a numeric session ID if you did not name the session, for example, <strong>tmux attach -t 0<\/strong>. But descriptive names are easier to remember than numbers.<\/p><h3 class=\"wp-block-heading\"><strong>Manage sessions<\/strong><\/h3><p>Effective session management prevents your server from filling up with unused background processes or &ldquo;zombie&rdquo; sessions. Check active sessions regularly to stay organized.<\/p><p>To list all active tmux sessions, run the following command in your main terminal:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux ls<\/pre><p>The output includes the following details:<\/p><ul class=\"wp-block-list\">\n<li><strong>Session name<\/strong>. The identifier you assigned or the default numeric ID.<\/li>\n\n\n\n<li><strong>Windows<\/strong>. The number of open windows in the session.<\/li>\n\n\n\n<li><strong>Created<\/strong>. The date and time when the session started.<\/li>\n\n\n\n<li><strong>Attached<\/strong>. Whether the session is currently in use.<\/li>\n<\/ul><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f700232f0\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-ls-1024x102.png\" alt=\"Terminal output listing active tmux sessions with tmux ls\" class=\"wp-image-137637\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>If you are currently inside a tmux session, you can switch to another one using the following command. As with reattaching, specify the session name or ID:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux switch -t session-name<\/pre><p>When you finish a task and no longer need the background processes, kill the session to free system resources.<\/p><p>To terminate the current session, type <strong>exit<\/strong> or press <strong>Ctrl + D<\/strong>. To kill a specific session without attaching to it, use the kill-session command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux kill-session -t session-name<\/pre><p>    <p class=\"warning\">\n        <strong>Warning!<\/strong> Use <strong>kill-session<\/strong> with caution. This command immediately stops all processes running in the session. If you have unsaved data in a text editor or an active database operation, you will lose it permanently.    <\/p>\n    \n\n\n\n<\/p><h3 class=\"wp-block-heading\"><strong>Create and navigate windows<\/strong><\/h3><p>A single tmux session can contain multiple windows, similar to tabs in a web browser or a GUI terminal application. This setup lets you keep different contexts separate within the same project without starting a new session.<\/p><p>For example, a typical workflow might include:<\/p><ul class=\"wp-block-list\">\n<li><strong>Window 0 (editor)<\/strong>. Running a text editor such as <strong>vim<\/strong> or <a href=\"\/ca\/tutorials\/how-to-install-and-use-nano-text-editor\">nano<\/a>.<\/li>\n\n\n\n<li><strong>Window 1 (server)<\/strong>. Running the web server or application.<\/li>\n\n\n\n<li><strong>Window 2 (git)<\/strong>. Executing <a href=\"\/ca\/tutorials\/basic-git-commands\">Git commands<\/a>.<\/li>\n<\/ul><p>To create a new window, press <strong>Ctrl + B &rarr; C<\/strong>. The new window appears in the status bar at the bottom of the screen, marked with a new number and an asterisk (<strong>*<\/strong>) to indicate that it is active.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f700250e7\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-session-window-number-asterisk-highlighted-1024x578.png\" alt=\"tmux window number with active asterisk highlighted in status bar\" class=\"wp-image-137638\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>To navigate between windows:<\/p><ul class=\"wp-block-list\">\n<li><strong>Next window<\/strong>. Press <strong>Ctrl + B &rarr; N<\/strong>.<\/li>\n\n\n\n<li><strong>Previous window<\/strong>. Press <strong>Ctrl + B &rarr; P<\/strong>.<\/li>\n\n\n\n<li><strong>Jump to a specific window<\/strong>. Press <strong>Ctrl + B<\/strong>, then a number key from <strong>0&ndash;9<\/strong> that matches the window ID.<\/li>\n<\/ul><h3 class=\"wp-block-heading\"><strong>Rename and organize windows<\/strong><\/h3><p>By default, tmux names each new window after the active process, usually <strong>bash<\/strong>, <strong>sh<\/strong>, or <strong>zsh<\/strong>.<\/p><p>In a complex session with several windows, names like &ldquo;bash&rdquo; make it hard to tell which window contains logs and which one holds your editor.<\/p><p>Rename windows to reflect their purpose and make navigation easier:<\/p><ol class=\"wp-block-list\">\n<li>Navigate to the window you want to rename.<\/li>\n\n\n\n<li>Press <strong>Ctrl + B &rarr; ,<\/strong> (comma).<\/li>\n\n\n\n<li>The status bar changes color and prompts you to edit the name.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f70027569\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-window-rename-window-highlighted-1024x578.png\" alt=\"tmux status bar showing window rename prompt highlighted\" class=\"wp-image-137639\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Delete the existing name, type a new one &ndash; for example, <strong>database<\/strong> &ndash; and press <strong>Enter<\/strong>.<\/li>\n<\/ol><p>The updated name appears immediately in the status bar, making window navigation faster.<\/p><h3 class=\"wp-block-heading\"><strong>Split windows into panes<\/strong><\/h3><p>Windows work well for separating distinct tasks, while panes let you divide a single window into multiple visible sections. This setup is ideal for multitasking when you need to cross-reference information.<\/p><p>For example, you might view real-time server error logs on the left side of the screen while triggering those errors by running commands on the right.<\/p><p>Use the following keybindings to split the current pane:<\/p><ul class=\"wp-block-list\">\n<li><strong>Split into left and right panes<\/strong>. Press <strong>Ctrl + B &rarr; Shift + 5<\/strong> (the <strong>%<\/strong> key).<\/li>\n\n\n\n<li><strong>Split into top and bottom panes<\/strong>. Press <strong>Ctrl + B &rarr; Shift + &lsquo;<\/strong> (the <strong>&ldquo;<\/strong> key).<\/li>\n<\/ul><p>You can combine these commands to build complex layouts. For example, split the window left and right first, then split the right pane into top and bottom sections.<\/p><p>This creates one large pane on the left and two smaller panes on the right.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f700290a3\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-window-pane-1024x564.png\" alt=\"tmux window split into multiple panes in a terminal\" class=\"wp-image-137640\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p><div><p class=\"important\"><strong>Important!<\/strong> tmux terminology can be counterintuitive. The <strong>%<\/strong> key creates a vertical divider, resulting in side-by-side panes. Meanwhile, <strong>&ldquo;<\/strong> creates a horizontal divider, resulting in stacked panes.<\/p><\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\"><strong>Navigate and resize panes<\/strong><\/h3><p>Once you split a window, typed commands affect only the currently active pane, which has a colored border. You need to move the focus to interact with other panes.<\/p><p>To switch between panes, press <strong>Ctrl + B<\/strong>, then use the arrow keys (<strong>Up<\/strong>, <strong>Down<\/strong>, <strong>Left<\/strong>, <strong>Right<\/strong>) to move in that direction. Alternatively, press <strong>Ctrl + B &rarr; O<\/strong> to cycle through panes sequentially.<\/p><p>Also, in some cases, the default <strong>50\/50<\/strong> split is not efficient. You might prefer a large coding pane and a smaller terminal output pane.<\/p><p>To resize panes, press <strong>Ctrl + B<\/strong>, then use <strong>Ctrl + arrow keys<\/strong>, such as <strong>Ctrl + Up<\/strong> or <strong>Ctrl + Down<\/strong>, to resize in steps of one cell. Use <strong>Meta + arrow keys<\/strong>, like <strong>Alt + Up<\/strong>, to resize in steps of five cells.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f7002ba54\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-window-pane-resized-1024x578.png\" alt=\"tmux window showing resized panes for custom terminal layout\" class=\"wp-image-137641\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\"><strong>Close panes<\/strong><\/h3><p>When you finish working in a pane, you can close it without affecting the rest of the window or session. There are three ways to do this, ranging from safe to forceful.<\/p><ul class=\"wp-block-list\">\n<li><strong>The shell method (recommended)<\/strong>. Type <strong>exit<\/strong> or press <strong>Ctrl + D<\/strong> in the command line. This safely ends the shell session, similar to logging out. If it is the last pane in the window, tmux closes the window.<\/li>\n\n\n\n<li><strong>The fast method<\/strong>. Press <strong>Ctrl + B &rarr; X<\/strong>. tmux displays a confirmation prompt at the bottom: <strong>kill-pane? y\/n<\/strong>. Press <strong>Y<\/strong> to confirm.<\/li>\n<\/ul><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f7002d982\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-tmux-window-pane-kill-pane-highlighted-1024x585.png\" alt=\"tmux confirmation prompt for killing a pane highlighted\" class=\"wp-image-137642\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ul class=\"wp-block-list\">\n<li><strong>The forced method<\/strong>. Press <strong>Ctrl + B &rarr; Shift + 7<\/strong> (the <strong>&amp;<\/strong> key). This kills the entire window and all panes inside it. Use this method only when you are sure you want to close everything in that view, as it can cause accidental data loss.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-tmux-keybindings-and-shortcuts\"><strong>Tmux keybindings and shortcuts<\/strong><\/h2><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Shortcut<\/strong><\/td><td><strong>Action<\/strong><\/td><td><strong>Description<\/strong><\/td><td><strong>Use case<\/strong><\/td><\/tr><tr><td><strong>Ctrl + B &rarr; D<\/strong><\/td><td>Detach session<\/td><td>Disconnects you from the session while keeping it running.<\/td><td>Log off SSH while a script continues to run.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; C<\/strong><\/td><td>Create window<\/td><td>Opens a new shell in a separate tab.<\/td><td>Separate a new task, such as database management, from your current task.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; Shift + 5 (%)<\/strong><\/td><td>Split left and right<\/td><td>Divides the screen into left and right panes.<\/td><td>Read code on one side and logs on the other.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; Shift + &lsquo; (&ldquo;)<\/strong><\/td><td>Split top and bottom<\/td><td>Divides the screen into top and bottom panes.<\/td><td>Keep a monitoring tool, like <strong>top<\/strong>, visible below your work.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; X<\/strong><\/td><td>Kill pane<\/td><td>Closes the active pane after confirmation.<\/td><td>Remove a split pane you no longer need.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; ,<\/strong><\/td><td>Rename window<\/td><td>Changes the window name shown in the status bar.<\/td><td>Organize complex sessions with many windows.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; Z<\/strong><\/td><td>Zoom pane<\/td><td>Toggles the active pane between full screen and normal view.<\/td><td>Temporarily focus on a specific log file without closing other panes.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; [<\/strong><\/td><td>Copy mode<\/td><td>Enters copy mode to scroll through terminal history. Press <strong>Q<\/strong> to exit.<\/td><td>Review previous output or copy text.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; W<\/strong><\/td><td>List windows<\/td><td>Shows an interactive list of all windows in the session.<\/td><td>Navigate sessions when you have too many windows to remember by number.<\/td><\/tr><tr><td><strong>Ctrl + B &rarr; Shift + \/ (?)<\/strong><\/td><td>List key bindings<\/td><td>Displays a help screen with all configured keybindings.<\/td><td>Quickly look up a shortcut you have forgotten.<\/td><\/tr><\/tbody><\/table><\/figure><h2 class=\"wp-block-heading\" id=\"h-how-to-customize-tmux\"><strong>How to customize tmux<\/strong><\/h2><p>To customize tmux, <strong>create or edit the .tmux.conf configuration file, then add your custom settings<\/strong>. After saving the file, apply the changes by running <strong>tmux source-file ~\/.tmux.conf<\/strong> inside a tmux session.<\/p><p>The configuration file can be local (applying only to your user) or global (applying to all users on the server). We recommend using a local configuration file to avoid disrupting other users.<\/p><h3 class=\"wp-block-heading\"><strong>1. Create the configuration file<\/strong><\/h3><p>The local configuration file is named <strong>.tmux.conf<\/strong> and resides in your home directory. Starting with version <strong>3.2<\/strong>, tmux also checks <strong>$XDG_CONFIG_HOME\/tmux\/tmux.conf<\/strong> (typically <strong>~\/.config\/tmux\/tmux.conf<\/strong>).<\/p><p>Create or edit the file using the nano text editor:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano ~\/.tmux.conf<\/pre><h3 class=\"wp-block-heading\"><strong>2. Add configuration options<\/strong><\/h3><p>You can add commands to change tmux behavior. Below are two common and recommended <a href=\"\/ca\/tutorials\/tmux-config\">tmux customizations<\/a>.<\/p><ul class=\"wp-block-list\">\n<li><strong>Change the prefix key<\/strong>. The default <strong>Ctrl + B<\/strong> shortcut can feel awkward to reach with one hand. Many users prefer <strong>Ctrl + A<\/strong>, similar to GNU Screen. Add the following lines to rebind it:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Unbind the default prefix\nunbind C-b\n\n# Set the new prefix to Ctrl + A\nset -g prefix C-a\nbind C-a send-prefix<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1f7002f594\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-nano-tmux-conf-1024x538.png\" alt=\"Nano editor displaying the .tmux.conf configuration file\" class=\"wp-image-137643\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ul class=\"wp-block-list\">\n<li><strong>Enable mouse support<\/strong>. Modern versions of tmux support mouse input. This lets you resize panes and scroll through history by clicking and dragging instead of relying only on keyboard shortcuts.<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">set -g mouse on<\/pre><p>After making your changes, save the file and exit <strong>nano<\/strong> by pressing <strong>Ctrl + X &rarr; Y &rarr; Enter<\/strong>.<\/p><h3 class=\"wp-block-heading\"><strong>3. Apply the changes<\/strong><\/h3><p>Saving the file does not apply changes to the running tmux server. tmux reads <strong>.tmux.conf <\/strong>only when the server starts, not when you create new sessions.<\/p><p>To apply the new configuration immediately without restarting the server, run the following command inside a tmux session:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tmux source-file ~\/.tmux.conf<\/pre><h2 class=\"wp-block-heading\" id=\"h-what-are-the-best-practices-for-using-tmux\"><strong>What are the best practices for using tmux?<\/strong><\/h2><p>Best practices for using tmux include <strong>creating a structured workspace, keeping sessions persistent and secure, and avoiding configuration bloat<\/strong>.<\/p><p>By treating tmux as a workspace manager rather than just a window splitter, you can significantly improve your command-line efficiency.<\/p><h3 class=\"wp-block-heading\"><strong>Organize workflows with tmux<\/strong><\/h3><p>Effective use of tmux starts with understanding its hierarchy: <strong>session &rarr; window &rarr; pane<\/strong>.<\/p><ul class=\"wp-block-list\">\n<li><strong>Sessions are for projects<\/strong>. Create a separate session for each major project, for example, <strong>client-website<\/strong> or <strong>server-maintenance<\/strong>. This approach prevents environment variables or command history from leaking between projects.<\/li>\n\n\n\n<li><strong>Windows are for tasks<\/strong>. Within a session, use windows for distinct tasks, like <strong>vim<\/strong>, <strong>database<\/strong>, or <strong>server-logs<\/strong>. Avoid cramming unrelated tasks into a single window.<\/li>\n\n\n\n<li><strong>Panes are for views<\/strong>. Use panes for immediate, side-by-side views, such as checking an error log while editing the code that caused it.<\/li>\n<\/ul><p><div class=\"protip\">\n                    <h4 class=\"title\">&#128161; Pro tip<\/h4>\n                    <p> Avoid running everything in a single window with many split panes. This makes the terminal hard to read and navigate. If a window becomes too cluttered, move a pane to its own window by pressing <strong>Ctrl + B &rarr; !<\/strong> (exclamation point).<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\"><strong>Recover from SSH disconnects<\/strong><\/h3><p>The most important function of tmux is session recovery. In a standard SSH session, if your Wi-Fi drops or your computer goes to sleep, the SSH connection breaks and sends a SIGHUP signal that terminates running commands.<\/p><p>tmux prevents this behavior. If your SSH connection times out:<\/p><ol class=\"wp-block-list\">\n<li>Log back into the server via SSH.<\/li>\n\n\n\n<li>Run <strong>tmux ls<\/strong> to find your previous session.<\/li>\n\n\n\n<li>Run <strong>tmux attach -t session-name<\/strong> to re-enter the environment.<\/li>\n<\/ol><p>Your cursor returns to the exact position where you left off, with command history and running processes intact.<\/p><h3 class=\"wp-block-heading\"><strong>Avoid common mistakes<\/strong><\/h3><p>Common tmux mistakes often come from treating it like a simple terminal tool rather than a session manager. Below are the most frequent issues and how to avoid them.<\/p><ul class=\"wp-block-list\">\n<li><strong>Nesting sessions<\/strong>. A common beginner mistake is running tmux inside an existing tmux session. This creates an &ldquo;Inception-like&rdquo; setup, where one tmux session runs inside another. It quickly becomes confusing because <strong>Ctrl + B<\/strong> commands affect only the inner session. To send the prefix to the inner session, you must press <strong>Ctrl + B<\/strong> twice. Avoid nesting unless you have a specific reason.<\/li>\n\n\n\n<li><strong>Forgetting to name sessions<\/strong>. While <strong>tmux new <\/strong>works, identifying the correct session from a list like <strong>0<\/strong>, <strong>1<\/strong>, or <strong>2<\/strong> is frustrating and error-prone. Always start sessions with a name using <strong>tmux new -s session-name<\/strong>.<\/li>\n\n\n\n<li><strong>Leaving unused sessions open<\/strong>. Each tmux session consumes memory. Idle sessions typically use only a few megabytes, but usage grows with the scrollback buffer size, which the <strong>history-limit <\/strong>option controls and defaults to 2000 lines per pane. Review active sessions regularly with <strong>tmux ls<\/strong> and remove unused ones with <strong>kill-session<\/strong>.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-whats-the-next-step-in-your-terminal-workflow\"><strong>What&rsquo;s the next step in your terminal workflow?<\/strong><\/h2><p>After learning how to use tmux, the next step in your terminal workflow is to<strong> integrate it with secure remote management practices to build a more robust server environment<\/strong>.<\/p><p>To get more value from remote sessions, check our guide on <a href=\"\/ca\/tutorials\/basic-ssh-commands\">essential SSH commands<\/a>.<\/p><p>It covers core tasks such as navigating directories, managing files, and editing configuration files, all of which you will perform regularly inside tmux sessions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A terminal multiplexer, or tmux, is a command-line tool that lets you manage multiple terminal sessions in a single window. With tmux, you can split panes, create multiple windows, and keep sessions active in the background. The primary benefit of tmux is persistence. If your SSH connection drops or you accidentally close your terminal emulator, [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/how-to-use-tmux\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to use tmux in %currentyear%","rank_math_description":"tmux is an application that lets you split terminal windows. Learn how to use tmux and find out some best practices. ","rank_math_focus_keyword":"how to use tmux","footnotes":""},"categories":[22699],"tags":[],"class_list":["post-15836","post","type-post","status-publish","format-standard","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-use-tmux","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/comment-utiliser-tmux","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-usar-tmux","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/tmux-cheat-sheet","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-use-tmux","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-use-tmux","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-use-tmux","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/que-son-hooks-wordpress-11","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/que-son-hooks-wordpress-11","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-usar-tmux","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-use-tmux","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-use-tmux","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-use-tmux","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-use-tmux","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=15836"}],"version-history":[{"count":50,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15836\/revisions"}],"predecessor-version":[{"id":141730,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15836\/revisions\/141730"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=15836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=15836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=15836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}