I've had an interesting terminal session in byobu, and I'd like to save the terminal output (commands and all) to a file - how can I do that?

According to the byobu man page:

Ctrl-a ~ - Save the current window's scrollback buffer

This may indeed be doing something, but I've found no indication of where and under what name it might be saved.

9 Answers 9


An old question still not workably answered for earlier byobu versions, and I hit the need again.

This time I found a workable solution. From man byobu:


   Each  window  in  Byobu  has  up to 10,000 lines of scrollback history,
   which you can enter and navigate using the alt-pgup and alt-pgdn  keys.
   Exit  this  scrollback mode by hitting enter.  You can also easily copy
   and paste text from scrollback mode.  To do so, enter scrollback  using
   alt-pgup  or  alt-pgdn,  press the spacebar to start highlighting text,
   use up/down/left/right/pgup/pgdn to select the text, and press enter to
   copy  the  text.  You can then paste the text using alt-insert or ctrl-
  1. I hit F7 to enter scrollback mode,
  2. Space to start selecting,
  3. gg to scroll to the top of the buffer (thanks @GeorgeMarian)
    • If that doesn't work, try this: either with lots of Page up or : followed by the largest line number (indicated top right) and Page up to get to the top of that page,
  4. Enter to copy (to byobu's clipboard, not a terminal/system one),
  5. then cat > my-byobu-dump.txt in the terminal,
  6. Alt+Insert or ctrl+A,] to paste (again, from byobu's clipboard)
  7. Ctrl+D to close the file.
  • This was the only answer that worked well for me. Oct 1, 2015 at 15:57
  • 1
    For step 3, if you want to get to the very top use gg (just like vim). Jul 27, 2017 at 17:32
  • @GeorgeMarian Do you know if that's from a vim-emulation mode? will people find other behaviours? Seems the default behaviour (at least with byobu 5.17 over tmux 1.6)
    – drevicko
    Jul 31, 2017 at 10:19
  • There's no vim-emulation mode in byobu that I know of. There's vi-like movement commands in scrollback mode, and maybe elsewhere. I just happened to try them, since -- well -- Linux. (I've been using less a lot lately, searching and moving around.) Aug 1, 2017 at 15:20
  • ok. could it be coming from the underlying multiplex technology (screen or tmux)? Anyway, I've added your suggestion. Many thanks :)
    – drevicko
    Aug 2, 2017 at 14:24

Or, you can simply use Byobu's hotkey for this:

  • Shift-F7

That will take your history and put it into $BYOBU_RUN_DIR/printscreen.

  • sift-F7 doesn't appear to do anything and the byobu help screen doesn't mention it either - I'm using byobu 5.17 with tmux 1.6 in ubuntu.
    – drevicko
    Jan 26, 2015 at 0:41
  • This is awesome, saved me a lot of time!
    – Ctrl-C
    Feb 25, 2015 at 12:59
  • 3
    I'm running byobu 5.74 and that option does appear for me in the help screen and works as described. I'd be surprised if that was not the case given that Dustin is the creator of byobu. :) Worth mentioning the output is saved at $BYOBU_RUN_DIR/printscreen (as noted in the help screen).
    – Chuim
    Apr 30, 2015 at 8:24
  • 3
    For me it was saved to /dev/shm/byobu-serg-ucvwj2rJ/printscreen, where serg is obviously my username Oct 2, 2015 at 4:01
  • 1
    I know this is an old answer. Anyhow, I experience the same issue: the shift-F7 seems not doing anything (even though the shortcut is present in the help menu). I'm using it on a Ubuntu-16.04 host with byobu version 5.106 & tmux 2.1.
    – Marc
    Apr 24, 2017 at 4:03

If you're used not to use the F-keys then this might work for you:

  • Ctrl+a, [: enter the scrollback mode
  • Space enter the copy mode (optional)
  • Enter exit the scrollback or copy mode
  • Ctrl+a, ]: paste what was copied

Where Ctrl+a is your tmux (default Byobu backend) prefix/escape sequence.

  • Also if your terminal program is intercepting the F-keys ;)
    – drevicko
    Jul 31, 2017 at 10:25
  • Get your current prefix key with tmux show-options -g | grep prefix May 9, 2020 at 17:15
  • 1
    that's something i have to remember! thank you very much! it worked for me, even with the screen backend, not tmux.
    – alex
    Nov 7, 2022 at 10:43

Shift + F7 only works as expected if you have the EDITOR environment variable set to an editor within byobu. For some reason, in some cases (e.g. for me when connecting through SSH to another computer), setting this variable in ~/.profile is not enough. One place to set it so that byobu always reads it is in ~/.bashrc. Copy something like the following to your ~/.bashrc:

# Although this is set in ~/.profile, it is set here as well so that in a 
# remote byobu session, Shift+F7 copies the output to a Vim buffer. See:
# https://askubuntu.com/questions/382750/how-to-save-scrollback-history-in-byobu
export EDITOR='vim'
  • In my case, this didn't help (actually .bashrc is where I set EDITOR anway). As far as I can tell, my terminal emulator (osx default Terminal program) isn't passing on the function keys correctly - probably solvable in Terminal's settings, but the ctrl-A solutions work ok for me.
    – drevicko
    Aug 23, 2017 at 9:59
  • 1
    @drevicko ah I see, good to know. Well, that's good that we are collecting several workarounds so that hopefully one of them will work for the next person who comes across this issue.
    – scottkosty
    Aug 23, 2017 at 22:18
  • fyi: .profile isn't loaded for ssh sessions by default - explains what happened here.
    – drevicko
    Aug 24, 2017 at 10:48

Use Ctrl+A+~ to copy the scrollback buffer to the byobu clipboard.

Paste the text into an editor using Alt+insert or Ctrl+A+].

(Adjust Ctrl+A if you've changed your escape key.)

  • I've only a Mac to work from at the moment, and ctrl-a ~ then ctrl-a ] aren't doing anything - I suspect ctrl-a isn't making it to byobu (which is at the other end of an ssh tunnel).. Any ideas?
    – drevicko
    Jul 31, 2014 at 13:15

If you need to save the history use Shift + F7 shorcut. Like @dustin-kirkland says.

If you prefer to scroll up and down in your terminal, It depends if you use tmux or screen. Examples:

  1. Screeen:

    • CTRL + a: If you use [ then, you enter in scroll mode like @ikar-pohorský says.
  2. Tmux:

    • ALT + PageUp: you scroll up.
    • ALT + PageDown: you scroll down.

Byobu F1 help


Ctrl+a, ? shows me that capture-pane and save-buffer are the key commands to save scrollback.

bind-key    -T root   S-F7             capture-pane -S -32768 ; save-buffer /dev/shm/byobu-asari-JG2wDS8x/printscreen ; delete-buffer ; new-window -n PRINTSCREEN " /dev/shm/byobu-asari-JG2wDS8x/printscreen"

When Shift+F7 doesn't work for you (e.g. when your terminal software consumes F-key events), try just as help says: Ctrl+a, :, capture-pane -S -32768 ; save-buffer /path/to/printscreen and Enter.


Select the text you wish to save, then press Control + Shift + C Next, open your favorite text editor. Then paste the content here using Control + V . Finally save the file in the desired location.

TERMINAL TIP OF THE DAY: When trying to copy something in terminal do it as usual expect use Control + Shift + C instead of Control +C, and paste as usual. For pasting something that is on the clipboard into the terminal use Control + Shift + V.

  • its just a simple copy paste scheme, will waste time to copy and then paste . drevicko wants to do it via terminal or automatically saves it somewhere .
    – Sukupa91
    Nov 27, 2013 at 3:13
  • Didn't he say I'd like to save everything to a file? This how he do it.
    – cubecubed
    Nov 27, 2013 at 3:17
  • 1
    No, I believe you'd just get on screen's worth - not the whole (perhaps 10000 line) byobu scrollback history... Note that byobu stores a terminal history that is independent of the terminal app your using.
    – drevicko
    Nov 27, 2013 at 3:18
  • If you hold the mouse above the window it will scroll up so that you can highlight the entire thing.
    – cubecubed
    Nov 27, 2013 at 3:20
  • 2
    @Cammy_the_block you're missing the "byobu" bit, look it up (a VERY handy thing if you're working on remote servers). It stores terminal sessions that you can disconnect from and later reconnect to. I have 10,000 lines of terminal history that is NOT accessible to the local terminal application. Byobu (and the backend it's using: tmux or screen) have their own set of keyboard driven commands to access that history.
    – drevicko
    Nov 27, 2013 at 4:11

Ctrl+A+] will work if you type from 1 to 20 times or more with abracodabra. But the only one command will work without headache to paste text from buffer to terminal or file is Alt+Ins. Byobu is GPLv3 software, authored and maintained by Dustin Kirkland.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .