{"id":166,"date":"2017-04-18T09:44:29","date_gmt":"2017-04-18T13:44:29","guid":{"rendered":"https:\/\/carleton.ca\/rcs\/?page_id=166"},"modified":"2026-04-09T10:49:47","modified_gmt":"2026-04-09T14:49:47","slug":"background-terminal-sessions","status":"publish","type":"page","link":"https:\/\/carleton.ca\/rcs\/rcdc\/background-terminal-sessions\/","title":{"rendered":"Background Terminal Sessions"},"content":{"rendered":"\n<section class=\"w-screen px-6 cu-section cu-section--white ml-offset-center md:px-8 lg:px-14\">\n    <div class=\"space-y-6 cu-max-w-child-5xl  md:space-y-10 cu-prose-first-last\">\n\n            <div class=\"cu-textmedia flex flex-col lg:flex-row mx-auto gap-6 md:gap-10 my-6 md:my-12 first:mt-0 max-w-5xl\">\n        <div class=\"justify-start cu-textmedia-content cu-prose-first-last\" style=\"flex: 0 0 100%;\">\n            <header class=\"font-light prose-xl cu-pageheader md:prose-2xl cu-component-updated cu-prose-first-last\">\n                                    <h1 class=\"cu-prose-first-last font-semibold !mt-2 mb-4 md:mb-6 relative after:absolute after:h-px after:bottom-0 after:bg-cu-red after:left-px text-3xl md:text-4xl lg:text-5xl lg:leading-[3.5rem] pb-5 after:w-10 text-cu-black-700 not-prose\">\n                        Background Terminal Sessions\n                    <\/h1>\n                \n                                \n                            <\/header>\n\n                    <\/div>\n\n            <\/div>\n\n    <\/div>\n<\/section>\n\n\n\n<p>It is possible to run&nbsp;Linux commands in the background. &nbsp;You are able to disconnect from the Virtual Machine (VM) and connect later, and commands continue to run in the background. &nbsp;This is useful&nbsp;if you&nbsp;need to run code that takes a long time.<\/p>\n\n\n\n<p><em class=\"myprefix-text-italic\">Thetmux<\/em> command on the Linux command-line\u00a0allows you to do exactly this. Using <em class=\"myprefix-text-italic\">tmux<\/em>\u00a0you can run commands\u00a0on the VM, logout, and reconnect to your running programs later.<\/p>\n\n\n\n<p>You can tell that you are running <em class=\"myprefix-text-italic\">tmux<\/em> by the green bar along the bottom of your Linux command-line window.<\/p>\n\n\n\n<h3 id=\"creating-a-new-session\" class=\"wp-block-heading\">Creating a new session<\/h3>\n\n\n\n<p>This command will start a new <em class=\"myprefix-text-italic\">tmux<\/em> session.\u00a0 You will see a new Linux command line that is running inside tmux.\u00a0 Each <em class=\"myprefix-text-italic\">tmux<\/em> session has a name, so you can have different sessions, and reference them by their unique names.<\/p>\n\n\n<div class=\"not-prose cu-quote cu-component-spacing\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>tmux new -s example01<\/p>\n<\/blockquote>\n<\/div>\n\n\n<h3 id=\"leaving-detaching-a-session\" class=\"wp-block-heading\">Leaving (detaching) a session<\/h3>\n\n\n\n<p>This leaves a session, but it will keep running so you can resume the session later. When you are in your <em class=\"myprefix-text-italic\">tmux<\/em> session, type:<\/p>\n\n\n<div class=\"not-prose cu-quote cu-component-spacing\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>Ctrl-b<\/em> followed by <em>d<\/em><\/p>\n<\/blockquote>\n<\/div>\n\n\n<h3 id=\"listing-sessions\" class=\"wp-block-heading\">Listing sessions<\/h3>\n\n\n\n<p>You can have more than one <em class=\"myprefix-text-italic\">tmux <\/em>session.\u00a0 To see the list of running sessions, use this command:<\/p>\n\n\n<div class=\"not-prose cu-quote cu-component-spacing\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>tmux&nbsp;ls<\/p>\n<\/blockquote>\n<\/div>\n\n\n<h3 id=\"resuming-attaching-a-session\" class=\"wp-block-heading\">Resuming (attaching) a session<\/h3>\n\n\n\n<p>When you want to reconnect to a session that you have already started, use this command:<\/p>\n\n\n<div class=\"not-prose cu-quote cu-component-spacing\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>tmux attach -t example01<\/p>\n<\/blockquote>\n<\/div>\n\n\n<h3 id=\"stopping-killing-a-session\" class=\"wp-block-heading\">Stopping (killing) a session<\/h3>\n\n\n\n<p>Once you are finished with a <em class=\"myprefix-text-italic\">tmux <\/em>session, you can get rid of it using this:<\/p>\n\n\n<div class=\"not-prose cu-quote cu-component-spacing\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>tmux kill-session -t example01<\/p>\n<\/blockquote>\n<\/div>\n\n\n<p>OR, type the Linux command <em class=\"myprefix-text-italic\">exit <\/em>inside your <em class=\"myprefix-text-italic\">tmux<\/em> session<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is possible to run&nbsp;Linux commands in the background. &nbsp;You are able to disconnect from the Virtual Machine (VM) and connect later, and commands continue to run in the background. &nbsp;This is useful&nbsp;if you&nbsp;need to run code that takes a long time. Thetmux command on the Linux command-line\u00a0allows you to do exactly this. Using tmux\u00a0you [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":96,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_cu_dining_location_slug":"","footnotes":"","_links_to":"","_links_to_target":""},"cu_page_type":[],"class_list":["post-166","page","type-page","status-publish","hentry"],"acf":{"cu_post_thumbnail":""},"_links":{"self":[{"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/pages\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":4,"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/pages\/166\/revisions"}],"predecessor-version":[{"id":1143,"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/pages\/166\/revisions\/1143"}],"up":[{"embeddable":true,"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/pages\/96"}],"wp:attachment":[{"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"cu_page_type","embeddable":true,"href":"https:\/\/carleton.ca\/rcs\/wp-json\/wp\/v2\/cu_page_type?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}