PageSourceSearch

https://mpolinowski.github.io/assets/js/1cebcda1.f5c8fc00.js

js mpolinowski.github.io collected 2026-10-03 09:40:30 UTC 8,058 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkmikes_dev_notebook=globalThis.webpackChunkmikes_dev_notebook||[]).push([[15969],{779324(e,n,t){t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>l,default:()=>h,frontMatter:()=>a,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"DevOps/Linux/2019-06-17--working-with-tmux/index","title":"Working with TMUX","description":"Wan Chai, Hong Kong","source":"@site/docs/DevOps/Linux/2019-06-17--working-with-tmux/index.mdx","sourceDirName":"DevOps/Linux/2019-06-17--working-with-tmux","slug":"/DevOps/Linux/2019-06-17--working-with-tmux/2019-06-17","permalink":"/docs/DevOps/Linux/2019-06-17--working-with-tmux/2019-06-17","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/DevOps/Linux/2019-06-17--working-with-tmux/index.mdx","tags":[{"inline":true,"label":"LINUX","permalink":"/docs/tags/linux"}],"version":"current","sidebarPosition":8090,"frontMatter":{"sidebar_position":8090,"slug":"2019-06-17","title":"Working with TMUX","authors":"mpolinowski","tags":["LINUX"]},"sidebar":"tutorialSidebar","previous":{"title":"CentOS 8 Network Configuration","permalink":"/docs/DevOps/Linux/2019-09-22--centos8-network-config/2019-09-22"},"next":{"title":"Downloading Docker Images for Offline Use","permalink":"/docs/DevOps/Linux/2019-06-14--download-and-save-docker-image/2019-06-14"}}');var s=t(474848),o=t(28453);const a={sidebar_position:8090,slug:"2019-06-17",title:"Working with TMUX",authors:"mpolinowski",tags:["LINUX"]},l=void 0,r={},d=[{value:"Installing tmux",id:"installing-tmux",level:2},{value:"Shell Splitting",id:"shell-splitting",level:2},{value:"Working with Windows",id:"working-with-windows",level:2},{value:"Detachment",id:"detachment",level:2}];function c(e){const n={a:"a",code:"code",em:"em",h2:"h2",img:"img",li:"li",p:"p",pre:"pre",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Wan Chai, Hong Kong",src:t(104987).A+"",width:"4902",height:"2699"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#installing-tmux",children:"Installing tmux"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#shell-splitting",children:"Shell Splitting"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#working-with-windows",children:"Working with Windows"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#detachment",children:"Detachment"})}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"http://tmux.sourceforge.net/",children:"tmux"})," is a terminal multiplexer. It allows you to access a tmux terminal using multiple virtual terminals. tmux takes advantage of a client-server model, which allows you to attach terminals to a tmux session. This means that you can run several terminals at once concurrently off of a single tmux session without spawning any new actual terminal sessions."]}),"\n",(0,s.jsx)(n.p,{children:"This also means that sudden disconnects from a cloud server running tmux will not kill the processes running inside the tmux session."}),"\n",(0,s.jsx)(n.h2,{id:"installing-tmux",children:"Installing tmux"}),"\n",(0,s.jsx)(n.p,{children:"Before installing tmux first update apt to ensure we have the latest packages. Then install tmux:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo apt-get update\r\nsudo apt-get install tmux\n"})}),"\n",(0,s.jsx)(n.h2,{id:"shell-splitting",children:"Shell Splitting"}),"\n",(0,s.jsx)(n.p,{children:"To begin a new tmux session:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"tmux\n"})}),"\n",(0,s.jsx)(n.p,{children:"As it is, you can treat this like a completely new terminal. In fact, it really is just a new terminal running from inside tmux. This new terminal is called a window in the context of tmux. Let's split our window into two panes."}),"\n",(0,s.jsxs)(n.p,{children:["tmux can be controlled using a prefix key (by default, Ctrl-b) and a command key. The command key to split into two panes is ",(0,s.jsx)(n.code,{children:"%"}),". From within tmux. We can also split our second pane horizontally with ",(0,s.jsx)(n.code,{children:"'"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Ctrl-b %\r\nCtrl-b '\n"})}),"\n",(0,s.jsx)(n.p,{children:"To switch to the next pane (panes are numbered left-to-right, top-down):"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Ctrl-b o\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Exiting out of a shell with ",(0,s.jsx)(n.code,{children:"exit"})," will destroy the associated pane. Adjacent panes will expand to make use of the freed space."]}),"\n",(0,s.jsx)(n.p,{children:"Closing the last pane will end tmux."}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"TMUX",src:t(822618).A+"",width:"874",height:"760"})}),"\n",(0,s.jsx)(n.h2,{id:"working-with-windows",children:"Working with Windows"}),"\n",(0,s.jsx)(n.p,{children:"A step in context above panes are windows. Windows behave similarly to tabs in a browser. To create a new window:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Ctrl-b c\n"})}),"\n",(0,s.jsx)(n.p,{children:"tmux will switch to the new window automatically. You can see the new window indicated in the status-line. Windows are numbered from 0, so our new window is number 1. Now you can create panes and treat this window like we did before. We can even create another window. Our three windows are numbered 0, 1, and 2."}),"\n",(0,s.jsx)(n.p,{children:"To move to the next window in the index:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Ctrl-b n\n"})}),"\n",(0,s.jsx)(n.p,{children:"To move backwards in the index:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Ctrl-b p\n"})}),"\n",(0,s.jsx)(n.h2,{id:"detachment",children:"Detachment"}),"\n",(0,s.jsxs)(n.p,{children:["When you exit the last shell in the last pane in the last window of a session, the session will terminate. Instead of exiting from the session entirely, you can ",(0,s.jsx)(n.em,{children:"detach"})," from the session."]}),"\n",(0,s.jsx)(n.p,{children:"A session will continue to run in the background, running whatever shells were on it when you detached."}),"\n",(0,s.jsx)(n.p,{children:"When you re-attach to the session later, you will return to the session in the same state it was when you detached. All windows and panes are retained by the session."}),"\n",(0,s.jsx)(n.p,{children:"To detach from a session:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"Ctrl-b d\n"})}
1),"\n",(0,s.jsx)(n.p,{children:"To re-attach to a session:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"tmux attach -t [session]\n"})}),"\n",(0,s.jsx)(n.p,{children:"Sessions, like windows, are numbered beginning from 0. If you forgot which session you wanted to attach to, you can view active sessions:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"tmux list-sessions\n"})}),"\n",(0,s.jsx)(n.p,{children:"A list of all command keys is accessible with:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"Ctrl-b ?\n"})})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},822618(e,n,t){const i=t.p+"assets/images/TMUX_01-217b89708b8aa9522c87efefeb76ee6a.png";t.d(n,["A",0,i])},104987(e,n,t){const i=t.p+"assets/images/photo-kt456d_645dhfh6dgjkhg4_d-1e94a9c3b49d7b7350ffa34ac77c127e.jpg";t.d(n,["A",0,i])},28453(e,n,t){t.d(n,{R:()=>a,x:()=>l});var i=t(296540);const s={},o=i.createContext(s);function a(e){const n=i.useContext(o);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:a(e.components),i.createElement(o.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.