if you detach from the tmux session, you will need to use this name when attaching this tmux at a later point.TMUX: a look at screen and dtach and byobu (tmux wins)

UPDATE 2020-11-10:

  • New tmux config. Scrolling is more percise (1 line per scroll action). Also preserve current path when creating new pane or window.

UPDATE 2019-07-31:

  • Tmux + clipboard works well with Windows on Cygwin:
    • you just need to use zoom (prefix key + z) and then select with Shift+Mouse Drag and it will put it into clipboard. zoom out with same key combo.
  • Tmux + clipboard works okay with MAC on Terminal:
    • you just need to use zoom (prefix key + z) and then select with Fn+Mouse Drag and it will put it into clipboard with Cmd+c; paste with Cmd+v. zoom out with same key combo.
  • By far the best though, is Tmux + clipboard on MAC with iTerm2:
    • you just need to use zoom (prefix key + z) and then select with Opt+Mouse Drag, it will auto put into clipboard. zoom out with same key combo.
    • Additionally, you can enable tmux’s clipboard to work with MAC clipboard: iterm2->Preferences->General->Enable Applications in terminal may access clipboard. Now you don’t need to zoom in, simply do a mouse drag to select and it will put selected text into clipboard. It even adheres to your pane and window dimensions

UPDATE 2019-07-26: On MAC and probably works with Linux as well, use config from 2016-10-27 or 2019-02-26 update. Then instead of Shift Key, use FN on terminal, or Option key on iterm. Articles: Keys on Mac, Copy + Paste.

UPDATE 2019-02-26: tmux that I use on work linux server (Centos 6.2 kernel 2.6.32-220). It uses some tmux plugins. Google tmux plugin manager (tpm): http://www.infotinks.com/tmux/home-dot-tmux-1.conf – I use screen like key bindings, here are the keys: screen tmux bindings

UPDATE 2016-10-27: I have installed the plugin manager for tmux which enabled mouse support in its windows and panes. Please check out the configuration file here: http://www.infotinks.com/tmux/home-dot-tmux.conf – I use screen like key bindings, here are the keys: screen tmux bindings

Command shortcut for tmux:

tmux ls instead of tmux list-sessions to list the sessions and their IDs (which will be the first number on each line, each line has a session)

tmux a -t0  instead of tmux attach-session -t0  to attach to session with ID 0.

My Favorite Setup Summed up (Summary I guess)

Here is my favorite setup so that I dont have to read through all of this. To get what I want. This will be helpful for you all to if you already know what tmux is and how to use it.

To start tmux just type : tmux

Here is a quick link to the bottom of the page with the SCREEN TMUX KEYBINDING:  screen tmux bindings

Quick Note To Remember if you read over everything:

Key thing to remember: check list of command man tmux or tmux list-commands and check current key bindings and all key commands inside tmux with control-b ? so thats control-b then shift-/ (or if your using control-a instead of control-b for your binding key, like how screen’s/byobu’s default keybindings are – see changing tmux key bindings option1 and option2, both covered options bring up help the same way – even though some other keys are different – so to bring up help with those methods you do control-a ? so thats control-a then shift-/ )

Main article starts now:

Tmux is a different program then screen. Some people compare byobu to tmux, but that’s incorrect (although technically okay as they seem to do the same thing, except tmux does it better). It all starts with a program called dtach, that allows to run a session under a process called init (so that if you close your putty screen, or detach from dtach- control \, then your programs still run). Then screen came out which gave you split screens and config files etc. Then byobu built upon screen, its just screen + a screen config modifier (that’s all byobu is, plus some helper programs), byubo can be set to launch on boot (but so can dtach and tmux and screen). Then you have tmux, which took from screen (and its 25+ years of code) and corrected its mistakes (screen is too slow to be updated)… So whats wrong with screen and thus dtach? Well reattaching to a session all of your regions (panes in tmux terms) are lost.

This character put in good terms (from forum: http://superuser.com/questions/423310/byobu-versus-gnu-screen-versus-tmux) :

“From an actual use case, the biggest difference between screen and tmux is how they handle split windows.

 A window in screen is a single pseudo-terminal. When attached to a screen session, you can split your terminal into multiple regions, each of which can display a screen window. Multiple regions can display the same window. The splits are not part of the session; if you detach, your splits are gone.

A window in tmux consists of one or more pseudo-terminals, one per pane. This means that panes persist if you detach and reattach later. It also means that you can display only one window at a time intmux, and that panes cannot be shared among multiple windows. tmux does allow a window to be shared among multiple sessions, however.

 I prefer the model used by tmux, but I couldn’t argue that it is better than the model used by screen.”

Also if you follow above link you will get more info about history of screen, byobu and tmux from the writer himself. In fact his next version of byobu will use tmux (I don’t know why though, tmux seems complete enough… maybe he will reintroduce its Control-a bind key back as default option)

Tmux How To

To get tmux:

Tmux opens a session (which has window and one giant pane). A window is a tab in tmux. A pane is the region where you do commands. A pane is actually just a pseudoterminal, a ptty if you will, so it will hold the bash session (more on that later when we look indepth on how tmux looks like from a process point of view). So at first tmux is as big as putty (aside from the green footer of info)

A good idea of the window, session, pane is shown here on Daniel Miesslers site and tmux primer article (have a read its great – and what got me started on tmux): http://www.danielmiessler.com/study/tmux/

Can split window to make more panes. One window can have many panes or 1 pane

A session can have many windows (tabs) and many panes per window

Also tmux remains running on the system until the last session is exited.

That puts me into 1 pane, in the main window, in the current and only session. These are some basic command:

The bind Key is control-b (unlike screen control-a and byobu control-a)

Meta is ESC. So if asks to hit META-UP. Then first do Control-b then ESC-UP. Meta sometimes seen as ^.


Back to showing tmux command line – To get out of tmux: control-b d

List sessions:

Attach to last session:

Attach to session by name(id number, left most when listing sessions):

Note: cant launch tmux from tmux (unless do magic, but don’t do it)

Note: cant move panes to diff sessions or windows.

Example: Just opened a new bash/putty shell and have not entered into tmux yet. I can make a new tmux session by typign “tmux” enter, or what I want to do is go into a current tmux session and end it:

Tmux has 2 sessions opened (each with windows and panes). Lets close tmux session with name 3

The -t is the name the name is the first number so 0 or 3

Note you can only attach and detach and connect to sessions (not windows and not panes alone) so each session will come with its many windows and panes.

I connect to session 3 (and out of each pane – by typing “exit” and enter as many times as there are panes open in the entirety of the session, closing out of each window and on final pane/window it exits the session)

Or I could of just

List the final sessions

To get all command:

 At command line can use autocompletion and argument detection (like cisco firewalls)

Tmux thinks ? Is a c (it lists all commands that start with c)

To see all commands begin with l

To see all of the tmux commands


Finally How do these panes and windows look like from a process point of view:

Process Tree of Tmux

I use the word tmux server (its the tmux process that sits closest to init/systemd that wont get affected by a shutdown of ssh/telnet/bash/console/terminal/putty) to mean the processes that houses all of the sessions (and thus windows and panes) as children – but they just look as pttys running as children to tmux server process. To turn off the tmux server you must exit out of all the panes/windows/ and finally sessions. (note closing out of all the panes, will close out of all the sessions & vice versa – look above at the difference between them)

I use the word tmux client to mean that a user behind an ssh/telnet/bash/console/terminal/putty (whatever) just attached to a ptty under the tmux server. The client will then see all of the output ment for him from that ptty, and all of the users input will be directed to that ptty.

tmux only has one process existing when its ran in the background, when your detached from all of its sessions (tmux server that holds all of the pseudoterminals, pttys – by the way a single ptty is open on the smallest tmux unit, which is a pane. So 1 pane is equal to 1 ptty). Even only 1 tmux process if you have a million panes and sessions. What holds the panes/pttys is the children of that singular tmux server process.

When you you have lets say 5 tmux sessions running in the background they are all forked off one tmux (tmuxserver – i will call it a server)

Then lets say you decide to attach to a tmux session then you will make another tmux process (tmux client process – i will call it client- i dontknow real term). From “ps aux” point of view they look the same

Lets attach to latest tmux:

Then from a tmux session or from a none tmux session lets view the tmux processes (either way they should look the same if im in or out of tmux):

So what happens when I open a new bash/putty and make a new tmux session. Well if there was no tmux running before. Then you make a tmux server and a tmux client. Then if you detach then you just leave a tmux server.

tmux client connect to sessions of a tmux server

tmux server holds the sessions, but to linux each tmux server looks like a parent to X number of bash processess (X being the number of total panes open)

Example of like 5 tmux sessions, each having like 2 windows or 3 windows, and each window having 1 to 3 panes (total of 19 pttys, or 19 panes scattered across the many windows opened across the 5 sessions):

TMUX keybindings change to be like that of SCREEN

Arch linux recommends this change, just change the main binding from Control-B to Control-A. Which is alot better and ergonomically easier to use. I will call that option1.

However I propose, and the rest of the tmux community propose, lets just change the tmux key-binding to be as close to screen as possible – this also takes on option1, plus many more changes to make it as close as possible to screen bindings. I call this option 2.

Note there are other options. They are saved as other config files (you will see them, but I doubt you will use them)

Config file

Tmux when loaded from a user looks for a setting file called:


It also looks for /etc/tmux.conf (im not sure if it append loads or just loads one of them, if you want universal settings for everything, just put everything in /etc/tmux.conf, because the ~/.tmux.conf are per-user config files). So if you want global settings just put everything in /etc/tmux.conf, and with regards to my article mentally and physically replace ~./tmux.conf with /etc/tmux.conf

To apply the config changes, first edit or make the config file tmux.conf in etc or .tmux.conf in your users home folder then reload tmux and the new settings should take place. IF THE SETTINGS DONT TAKE IN: exit out of tmux, andkill every tmux session, an easy way to do that is killall tmux  and repeat that (but becareful not too kill it if you really need something that is running)

If its missing it loads its default tmux key bindings (so if you want to revert back to tmux keys in the future, just rename or remove .tmux.conf)

For option1 we will edit the file (use vim or something “ vim ~/.tmux.conf “, press “ i ” in vim to insert/type , press “ ESC :wq! ” in Vim to save and exit)

For option2 we will just copy over that file (it will create it in the process)

NOTE: it seems in arch the config file might not be .tmux.conf, but might just be tmux.conf. You can search the system for it like this (xdev option to stay in the same root filesystem – so it doesnt explore other filesystems, dont -xdev use if you think your tmux.conf might be in another filesystem, like if you partitioned your home folder into a different partition – SIDENOTE: -xdev and -mount are the same thing, so either write -xdev or -mount):

Option1: Arch change: Control-b to Control-a

To take on just the key change of Control-b to Control-a and keep tmux bindings mostly the same follow the instructions in arch’s tmux article: https://wiki.archlinux.org/index.php/tmux

In ~/.tmux.conf, just put this:

Save and exit out of your editor to save changes to ~/.tmux.conf

To take on the effect you will

Now all of the bindings are the same as I wrote above, but instead of preceding every key command with Control-b just use Control-a (its easier on the fingers). Look below for complete list

Here are the new bindings (option1 just change control-b to be control-a):


Option2: Change to screen bindings (Control-b to Control-a included)

Again this will change tmux keybindings to match that of screen, so for one you get the whole Control-b to Control-a change plus alot more.

First find the config file, for me they are located in (debian 7):

I notice for some other users they are in:

For debian users – it all here probably:

So for some people its:

Long story short if your Debian user most likely your config will lie in the mentioned spot so do this:

If your config lies elsewhere do this:

If in tmux, changes wont take effect until you get out and get back in (sessions can still be running thats fine). If your not in tmux next time you go in tmux your changes will take on effect.

NOTE: if your config file is not in either of those places look it up like this, and make sure you have the latest version of tmux

On debian build – this will list all of the files included in your tmux install – so look where your conf files are at specifically the screen binding conf file:

Note My version is:

None debian then just use find (one of them) to locate your tmux conf files (look for all files, that have tmux in their fullpath, and then only handpick out and show me the conf files):

That should output where your conf files are

NOTE ON xdev: xdev option to stay in the same root filesystem – so it doesnt explore other filesystems, dont -xdev use if you think your tmux.conf might be in another filesystem, like if you partitioned your home folder into a different partition – SIDENOTE: -xdev and -mount are the same thing, so either write -xdev or -mount

Here are the new bindings (option2, screen like settings in tmux):

NOTE: notice there really is not much difference between option1 and 2


BYOBU can be run with TMUX instead of SCREEN

I just prefer good ol’ regular tmux, but thats how you have to have tmux

Install note: first installed byobu and then tmux (dont know if order matters, probably not)

Starting TMUX on every login

Don’t do this. Just manually run it every time. This way you have control over what session you attach to.

Check out the information here:

Leave a Reply

Your email address will not be published. Required fields are marked *