57

Currently I don't seem able to run multiple sessions of byobu. After the initial byobu instance, running on one terminal, when I run byobu in another terminal it always attaches to the first byobu session.

Is there away to start independent byobu sessions?

5 Answers5

73

It is very easy. (At least on my ubuntu 10.04 machine, where byobu uses screen.);

If you already have one session running, and do not want to reattach but instad create a new one, just type:

byobu -S my-other-session

Where my-other-session is how you are naming the new session.

Later, if you have already more than one byobu sessions running, it is sufficient to type

byobu

And you will be presented with a list of running sessions to choose from:

Byobu sessions...

  1.  17680.my-other-session (03/12/2012 01:33:32 PM) (Detached)
  2.  11890.pts-2.mit        (01/15/2012 09:17:49 AM) (Detached)
  3.  Create a new session

Choose 1-3 [1]:

If typing byobu dos not present a list of running sessions to choose from, try the byobu-select-session command.

The pts-2.mit session was the one I created initially without giving it a name, so the name was chosen by boybu.

If you want to find out which sessions are running, without attaching to any of them, use

byobu -ls

It drops you again at the console where you typed it after showing a list like:

There are screens on:
        17680.my-other-session  (03/12/2012 01:33:31 PM)        (Detached)
        11890.pts-2.mit         (01/15/2012 09:17:48 AM)        (Detached)
2 Sockets in /var/run/screen/S-root.
mit
  • 2,121
  • 4
    For byobu with tmux I found these answers useful:
    http://askubuntu.com/questions/470208/use-multiple-byobu-sessions-while-ignoring-unrelated-tmux-sessions
    http://askubuntu.com/questions/196290/name-a-byobu-session
    – mp3foley Apr 16 '15 at 02:12
9

Use the -S option to give your next byobu session (e.g. its socket) a different name. Without -S "MYNAME" the socket would be <pid>.<tty>.<host> instead of <pid>.MYNAME.

Eliah Kagan
  • 117,780
trv
  • 91
8

As far as I can work out, if you run byobu with no arguments then it reattaches to an existing session (or starts a new one if you aren't running byobu at all). If you run it with a program name as the argument then it will pass this to either screen or tmux, depending on what you are running inside.

If you're running screen, you can simulate starting a fresh session (executing your shell) by running byobu byobu-shell (byobu-shell being the program that byobu launches by defualt. It prints the MOTD and launches your $shell.). Then when you try to reattach, either by running byobu or reconnecting via SSH to the server, you'll be given a menu with options to choose between the running byobu sessions.

For tmux, execute byobu new-session to achieve this. The next time you reconnect you'll be attached to the last session you started.

Iain Lane
  • 2,977
  • :Thanks for your reply. But running byobu $shell just reattaches to the already running session (this is because $shell is not defined/blank in the terminal). While running byobu byobu-shell just gives prints that byobu-shell is an unrecognised command. (Sorry if I have misunderstood what you said...) – hargriffle Jan 11 '12 at 11:17
  • What release are you running? byobu-shell is in Oneiric and newer. You can run byobu bash (or zsh or whatever) to get roughly the same effect. – Iain Lane Jan 11 '12 at 11:31
  • I am running ubuntu 10.04, byobu version 5.2 and tmux 1.5. And, unfortunately, both byobu bash and byobu zsh given "unknown command" errors. Is it perhaps something in my old screen set up? Any ideas? – hargriffle Jan 11 '12 at 11:40
  • I can't easily test Lucid I'm afraid, but if you're up for it you could install a newer version from the PPA: https://launchpad.net/~byobu/+archive/ppa/+packages – Iain Lane Jan 11 '12 at 11:41
  • OK I reinstalled byobu using (byobu - 5.2-0ubuntu1~ppa2, the one for Lucid). byobu -v prints byobu version 5.2 and tmux 1.5 (same as earlier). But this has made no difference, byobu is still not recognising the second argument (bash, zsh etc). – hargriffle Jan 11 '12 at 12:31
  • Ah, sorry, I thought you were using screen for some reason. Reading from the man page, ("Options to byobu are simply passed through screen(1) or tmux(1).") you might be able to do this with new-session, i.e. byobu new-session. I think that when reattaching in the tmux case, you'll be reattached to the most recently created session by default. I'm sorry that I can't test this for you at the minute; my internet has gone wonky. :( – Iain Lane Jan 11 '12 at 13:50
  • Excellent. The command byobu new-session does exactly what I was looking for -- perhaps you can edit your answer or should I add another answer? Not quite sure of the protocol here! Many thanks for your help. – hargriffle Jan 11 '12 at 14:45
  • There we go, done. Glad we got there. – Iain Lane Jan 11 '12 at 16:43
  • I'm still puzzled. I ssh to my Ubuntu server. It starts up screen/byobu, and presents me with something that looks like a curses-managed display (i.e. my terminal scrollbars are broken.) When I do the same thing from a second terminal, both terminals are looking at the same session. Typing "byobu new-session" resets the session in both terminals. I still only have one session, albeit two windows on to it. – Jonathan Hartley Feb 24 '12 at 11:58
  • 1
    The command I wanted was "byobu-disable", then reconnect as many times as you need. This isn't a solution to the precise OP, but it allows two different terminal sessions at once (without byobu), which is all I need. – Jonathan Hartley Feb 24 '12 at 12:02
2

If you're connecting to a machine using ssh and you'd like to create a new byobu session, use:

ssh -t hostname byobu new-session

Note: The -t flag is needed to "Force pseudo-terminal allocation" otherwise you get the following error: "open terminal failed: not a terminal"

Once you have created the new session on a machine on any subsequent connection you'll be asked which byobu session you'd like to attach to.

Pierz
  • 3,063
  • 1
  • 25
  • 15
1

Or, when you are inside a byobu session already: Ctrl+Shift+F12.

Eliah Kagan
  • 117,780
taper
  • 218