{"id":64,"date":"2016-07-19T02:48:26","date_gmt":"2016-07-19T02:48:26","guid":{"rendered":"http:\/\/wizardofbots.com\/network\/?p=64"},"modified":"2016-07-19T02:48:26","modified_gmt":"2016-07-19T02:48:26","slug":"the-nicest-way-of-leaving-your-code-working-remotely-using-tmux","status":"publish","type":"post","link":"https:\/\/wizardofbots.com\/network\/the-nicest-way-of-leaving-your-code-working-remotely-using-tmux\/","title":{"rendered":"The nicest way of leaving your code working remotely using TMUX"},"content":{"rendered":"<p>TMUX is tha maaaaan! Sure as death that you are going to love this! Remember when you ran a scan on a remote VPS? every time that you left it working it got the broken pipe, so you lost the session and you don&#8217;t get the results you wanted till the end of the code.<\/p>\n<p>But with TMUX, you can leave running many SSH &#8220;sessions\/terminals&#8221; working many processes. You can leave scrapers, scanners, crawlers, and even an app working on nginx\/apache. Its like using all the process of your VPS and not losing any single fucking penny!<\/p>\n<p>Its something like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/media.giphy.com\/media\/xCjz6HAYhoTEA\/giphy.gif\" width=\"620\" height=\"320\" \/><\/p>\n<p>So let&#8217;s get physical now, for having tmux, of course you need to have linux on any provider you want, it can be 512 MB RAM, $5 USD on <a href=\"https:\/\/m.do.co\/c\/4fa73dd93a0c\" target=\"_blank\">Digitalocean<\/a>. Then once you have it, connect via SSH on the terminal like: ssh root@ip.<\/p>\n<p>Once you are in, make sure you have tmux installed:<\/p>\n<blockquote><p>sudo apt-get install tmux<\/p><\/blockquote>\n<p>Then, to open make sure to type <strong>tmux <\/strong> on the terminal and it will open.<\/p>\n<p>So basic navigation on the tmux would be this by default:<\/p>\n<ul>\n<li><strong><em>Ctrl-b c<\/em><\/strong> Create new window<\/li>\n<li><strong><em>Ctrl-b d<\/em><\/strong> Detach current client<\/li>\n<li><em><strong>Ctrl-b l<\/strong><\/em> Move to previously selected window<\/li>\n<li><em><strong>Ctrl-b n<\/strong><\/em> Move to the next window<\/li>\n<li><em><strong>Ctrl-b p<\/strong><\/em> Move to the previous window<\/li>\n<li><em><strong>Ctrl-b &amp;<\/strong><\/em> Kill the current window<\/li>\n<li><em><strong>Ctrl-b ,<\/strong><\/em> Rename the current window<\/li>\n<li><em><strong>Ctrl-b %<\/strong><\/em> Split the current window into two panes<\/li>\n<li><em><strong>Ctrl-b q<\/strong><\/em> Show pane numbers (used to switch between panes)<\/li>\n<li><em><strong>Ctrl-b o<\/strong><\/em> Switch to the next pane<\/li>\n<li><em><strong>Ctrl-b ?<\/strong><\/em> List all keybindings<\/li>\n<\/ul>\n<p>The trick here is that you can have as many SSH windows you want doing <strong>Ctrl-b c <\/strong>and then running other process that you can navigate with <em><strong>Ctrl-b n<\/strong><\/em> and\u00a0<em><strong>Ctrl-b p\u00a0<\/strong>(from next, previous)<\/em> , else you can have your window split if you do <strong>Ctrl-b % <\/strong> and you can watch all in panels.<\/p>\n<p><strong>IMPORTANT: <\/strong>If you want to exit TMUX and leave the session working with the scripts you ran, you have to do <strong>CTRL-B D <\/strong> which means it will detach.<\/p>\n<p>Then afterwards, when you come back from your procrastination you can go and type:<\/p>\n<blockquote><p><strong>tmux attach <\/strong><\/p><\/blockquote>\n<p>Which will make you restore your tmux session that you left working with other processes.<\/p>\n<p>Then when you come back to your session, you will see everything is finished or keep running extracting more data<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-65 size-full\" src=\"http:\/\/wizardofbots.com\/network\/wp-content\/uploads\/2016\/07\/tmux1.jpg\" alt=\"tmux1\" width=\"654\" height=\"459\" srcset=\"https:\/\/wizardofbots.com\/network\/wp-content\/uploads\/2016\/07\/tmux1.jpg 654w, https:\/\/wizardofbots.com\/network\/wp-content\/uploads\/2016\/07\/tmux1-600x421.jpg 600w, https:\/\/wizardofbots.com\/network\/wp-content\/uploads\/2016\/07\/tmux1-300x211.jpg 300w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/p>\n<p>So now you know how to take the most of what you pay for the VPS, hope you like it and leave the love dudes ;).<\/p>\n<p>Here is a good vid that explains deeply more about tmux:<\/p>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/BHhA_ZKjyxo\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>TMUX is tha maaaaan! Sure as death that you are going to love this! Remember when you ran a scan on a remote VPS? every time that you left it working it got the broken pipe, so you lost the session and you don&#8217;t get the results you wanted till the end of the code. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[7,8,37,36,9],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-ssh","tag-tips","tag-tmux","tag-tutorials"],"_links":{"self":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":1,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":66,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts\/64\/revisions\/66"}],"wp:attachment":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}