# Terminal Multiplexers

Working with code and programs in persistent terminal sessions allow your work to run even when you disconnect from your virtual machine. For example, to resume your work back home or to keep your code running if your internet connection get lost for a while.

Thus, it may be good to investment a little bit of time to read up identifying your favorite terminal multiplexer. Below are a couple of popular terminal multiplexers that are all preinstalled on your HUNT Cloud machine.

# GNU Screen

GNU Screen (opens new window) is one of the most popular terminal multiplexers out there and is a great starting point.

# Start a new session

Start a virtual session on your computer with:

screen -S testsession

You may see a blink on the screen or a Screen welcome menu, and then something that resembles your regular terminal window.

# List sessions

Now let's try to list your running sessions (you can have many running at once):

screen -ls

You should see something like:

There are screens on:
        <number>.testsession        <time> (Attached)

This means that you are attached to the virtual session named testsession. Write some random text in your command line within the session to mimic come work before we try to attach the session.

# Detach your session

Detach your session holding down the Ctrl key together with A and D:

Ctrl + A + D

Your screen should blink again and you should see something like this in your terminal:

[detached from <number>.testsession]

# Resuming a session

First list the sessions again using screen -ls as described above. You should expect something like this:

There are screens on:
  <number>.testsession  <time>  (Detached)

This means that your session is still alive on your computer. This session can now be resumed with the command screen -r <sessionname>:

screen -r testsession

You should now see the random text that you left in inside your session before you detached.

# Terminating a session

Terminate your session with exit.

exit

# Learning more about Screen

If you want to learn more about Screen, including how to use multiple windows and split screens check out the How to Install and Use Screen on an Ubuntu Cloud Server (opens new window) tutorial or the comprehensive Screen User's Manual (opens new window).

# tmux

tmux (opens new window) is a newer and popular alternative to GNU Screen. There are many good online introductions to tmux such as A Quick and Easy Guide to tmux (opens new window) and the online book The Tao of tmux (opens new window).

# Byobu

Byobu (opens new window) is a handy wrapper for both tmux and GNU Screen. It includes an enhanced profiles, convenient keybindings, configuration utilities, and toggle-able system status notifications for both the GNU Screen window manager and the more modern Tmux terminal multiplexer, and works on most Linux, BSD, and Mac distributions.