Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2483,"date":"2019-12-06T00:24:58","date_gmt":"2019-12-06T00:24:58","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2483"},"modified":"2019-12-14T19:27:11","modified_gmt":"2019-12-14T19:27:11","slug":"boost-productivity-with-tmux-on-ubuntu-and-centos","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/boost-productivity-with-tmux-on-ubuntu-and-centos\/","title":{"rendered":"Boost Productivity with Tmux on Ubuntu and CentOS"},"content":{"rendered":"

Introduction<\/strong><\/h2>\n

Tmux is a terminal multiplexer. It allows you to run and manage several command prompts simultaneously from one tmux session. It is the equivalent of a graphical window manager, for command prompts.<\/p>\n

Tmux uses a client\/server model which allows it to persist connections.<\/strong>\u00a0This means that you can start a session from one computer\u00a0(say your work computer)<\/strong>, have several programs running on it, leave work and connect back to the same session from a different computer\u00a0(say your home computer)<\/strong>. When reconnecting to your session, you will continue where you left – the same programs will be running.<\/p>\n

Installation<\/strong><\/h2>\n

On Debian\/Ubuntu systems use:<\/strong><\/p>\n

sudo apt-get update && sudo apt-get -y install tmux\r\n<\/code><\/pre>\n

On Redhat\/CentOS systems use:<\/strong><\/p>\n

sudo yum install update && sudo yum -y install tmux\r\n<\/code><\/pre>\n

Note:<\/strong>\u00a0“-y”<\/span><\/strong>\u00a0in both cases above auto answers\u00a0“yes”<\/span><\/strong>\u00a0during installs.\u00a0Above commands were tested on Ubuntu 12,14 & 16 and CentOS 6 & 7.<\/strong><\/p>\n

Terminology<\/strong><\/h2>\n

Pane<\/strong>\u00a0– A pane is simply a\u00a0terminal prompt.<\/strong>
\nWindow<\/strong>\u00a0– A window holds multiple\u00a0panes (terminals)<\/strong>\u00a0on one screen.
\nSession<\/strong>\u00a0– A session has multiple windows. Sessions are similar to applications that\u00a0create virtual\/multiple desktop<\/strong>\u00a0workspaces like\u00a0GNOME on Linux and VirtualWin on Windows.<\/strong><\/p>\n

Usage<\/strong><\/h2>\n

Start a new tmux session<\/strong><\/h4>\n
tmux new -s start\r\n<\/code><\/pre>\n

You will see a bar at the bottom of the screen with the session name\u00a0“start”<\/strong><\/span>\u00a0in brackets. What just happened, was that tmux started a new session named\u00a0“start”<\/strong><\/span>\u00a0that contained a default window holding one\u00a0pane (terminal)<\/strong>. Upon creating a pane,\u00a0tmux automatically logs<\/strong>\u00a0you in with your user account.<\/p>\n

Maneuvering in tmux<\/strong><\/h4>\n

Once inside a tmux session<\/strong>, you use a prefix key to trigger commands to tell tmux what to do. The default prefix key is\u00a0CTRL + b<\/strong>. For example, if you want to tell tmux to create a new pane by splitting your screen into\u00a0two vertical sections<\/strong>, you first hit\u00a0CTRL + b<\/strong>, then\u00a0%<\/strong>.<\/p>\n

Create Multiple Panes<\/strong><\/h4>\n

If you already keyed in\u00a0CTRL + b<\/strong>, then\u00a0%<\/strong>\u00a0above, then you will see that you already have two panes on your screen.<\/p>\n

Split the current pane into\u00a0two horizontal sections<\/strong>\u00a0by keying<\/span>\u00a0CTRL + b<\/strong>, then\u00a0“<\/strong>.<\/p>\n

To\u00a0rotate\/cycle<\/strong>\u00a0through all three panes use\u00a0CTRL + b<\/strong>, then\u00a0o<\/strong>.<\/p>\n

Create Multiple Windows<\/strong><\/h4>\n

Lets create a new window inside of the same\u00a0“start”<\/strong><\/span>\u00a0session that we are already in. Hit\u00a0CTRL + b<\/strong>, then\u00a0c<\/strong>. You will see a new blank terminal.<\/p>\n

Split this terminal into two horizontal panes –\u00a0CTRL + b<\/strong>, then\u00a0“<\/strong>.<\/p>\n

Create a third window\u00a0CTRL + b<\/strong>, then\u00a0c<\/strong>. You will see a new blank terminal again. Issue the command\u00a0tmux list-windows<\/code>, then press\u00a0ENTER<\/strong>\u00a0to confirm that you have 3 windows opened.<\/p>\n

Use\u00a0CTRL + b<\/strong>, then\u00a0n<\/strong>\u00a0to cycle between the three windows created.<\/p>\n

Attach and Detach to\/from a Session<\/strong><\/h4>\n

Use\u00a0CTRL + b<\/strong>, then\u00a0d<\/strong>\u00a0to detach from your current session (this should be the\u00a0“start”<\/strong><\/span>\u00a0session created earlier).<\/p>\n

Reconnect back to\u00a0start session<\/strong>\u00a0using\u00a0tmux attach -t start<\/code>. Use\u00a0CTRL + b<\/strong>, then\u00a0n<\/strong>\u00a0to cycle between the three windows in start session.<\/p>\n

When at another location\u00a0(or on a different machine)<\/strong>,\u00a0SSH<\/strong>\u00a0into your server. After logging in, issue the\u00a0tmux attach -t start<\/code>\u00a0command. You will see that it connects you to the start session with all three windows running intact.<\/p>\n

Conclusion<\/strong><\/h2>\n

As already stated,\u00a0tmux is the equivalent of a graphical windows manager<\/strong>, but for command prompts. It is sure to boost your productivity significantly, and is comparable to tabs for browsers.<\/p>\n

You can take things further by using configuration tools for tmux like\u00a0teamocil<\/span><\/a><\/strong>\u00a0and\u00a0tmuxifier<\/span><\/a><\/strong>\u00a0to define better workflows.<\/p>\n

Some Useful Commands<\/strong><\/h3>\n

Common key bindings<\/strong><\/h4>\n

CTRL + b<\/strong>, then\u00a0c<\/strong>\u00a0– Create new window.
\nCTRL + b<\/strong>, then\u00a0,<\/strong>\u00a0– Rename window.
\nCTRL + b<\/strong>, then\u00a0n<\/strong>\u00a0– Move to the next window.
\nCTRL + b<\/strong>, then\u00a0p<\/strong>\u00a0– Move to the previous window.
\nCTRL + b<\/strong>, then\u00a0&<\/strong>\u00a0– Kill current window.
\nCTRL + b<\/strong>, then\u00a0%<\/strong>\u00a0– Split current pane into two (vertically).
\nCTRL + b<\/strong>, then\u00a0“<\/strong>\u00a0– Split current pane into two (horizontally).
\nCTRL + b<\/strong>, then\u00a0o<\/strong>\u00a0– Switch to next pane.
\nCTRL + b<\/strong>, then\u00a0q<\/strong>\u00a0– Show pane numbers (then type a # to switch to it).
\nCTRL + b<\/strong>, then\u00a0d<\/strong>\u00a0– Detach from current session.
\nCTRL + b<\/strong>, then\u00a0?<\/strong>\u00a0– List all key bindings.<\/p>\n

Common session commands<\/strong><\/h4>\n

tmux list-sessions<\/code>\u00a0–\u00a0List existing tmux sessions.<\/strong>
\ntmux new -s session-name<\/code>\u00a0–\u00a0Create a new tmux session named session-name.<\/strong>
\ntmux attach -t session-name<\/code>\u00a0–\u00a0Connect to an existing tmux session named session-name.<\/strong>
\ntmux switch -t session-name<\/code>\u00a0–\u00a0Switches to an existing tmux session named session-name.<\/strong><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[231,242,247],"manual_kb_tag":[311],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2483"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2483"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2483\/revisions"}],"predecessor-version":[{"id":2484,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2483\/revisions\/2484"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2483"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2483"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}