Save and restore terminal on reboot

Is there a way to save my terminal emulator windows and tabs for when I reboot the computer?

I generally have about 10 or so open tabs at any given time and opening each tab to set up everything after a reboot is relatively long. I would like to at least save the current working directories and name each tab works with so I can be more efficient.

If it helps, I am running Xubuntu 14.04.


The following method does not save the directories upon exit. It uses always the same directories until you change them in "Preferences", although you may have multiple indipendent groups of directories.

We will install "terminator".

These are the step-by-step instructions for three tabs. The steps are the same for any number of tabs.


sudo apt-get install terminator

Alternatively, you can install it with aptitude, or ubuntu software center.

  • Run terminator, f.e. from the "KDE" menu.
  • Right-click on the black screen.
  • Click "Open tab".
  • Then again, right-click on the black screen.
  • Click "Open tab".
  • Then again, right-click on the black screen.
  • Click "Preferences"
  • Click on the "Layouts" tab.
  • Click "Add".
  • Write a name and press ENTER. I will use the name "mylayout" in this procedure. Do NOT click "Save".

You can see on the right pane the words: "Window", "Notebook", "Terminal", "Terminal", "Terminal".


  • Click on the LOWEST of the words "Terminal".
  • Click inside the blank field to the right of "Working directory:".
  • Write the path of the directory which you want to be the first tab; f.e. /a/dir1.
  • Click on the word "Terminal" just above the lowest one.
  • Click inside the blank field to the right of "Working directory:".
  • Write the path of the directory which you want to be the second tab.
  • Click on the HIGHEST of the words "Terminal".
  • Click inside the blank field to the right of "Working directory:".
  • Write the path of the directory which you want to be the third tab.
  • Click "Close".
  • Click the "X" in the upper right corner to close terminator.

  • Right click on an empty space of the desktop.
  • Click "Create new".
  • Click "Link to application".
  • Click the tab "Application".
  • Click inside the blank field to the right of "Command:".
  • Write:

    terminator --layout=mylayout
    
  • Click "OK".


Now click on the new icon. You should see all your tabs.

You can create multiple layouts in the same way, and you can modify the directories and other settings by right-clicking on the black screen and clicking "Preferences".


As suggested by Bram, you can use a Terminal multiplexer (such as screen) to accomplish this.

Paraphrased from Wikipedia, terminal multiplexers allow:

  • Users to connect and disconnect from terminal sessions.
  • Have multiple terminal sessions in one window (similar to the tabs you suggested, or splitting a vim window).
  • Multiple users to access the same session.

If you used a terminal multiplexer such as tmux, there is a superuser thread asking how to save sessions over reboot. You could use install this suggested plugin called tmux-ressurect, and then your sessions, windows, panes, etc will be saved.

The default tmux prefix key is Ctrl+b, so in tmux once tmux-ressurect is installed to:

  • save your session , you can press Ctrl+b + Crtl+s.
  • restore your tmux session, you can press Ctrl+b + Crtl+r.

I don't know if you can do so with a terminal directly. But you could try screen.

It will not survive a reboot but you can define the tabs etc. you need so you can open them quickly.