Learn to Use the tmux Terminal Multiplexer on Oracle Linux 8


This tutorial provides step-by-step procedures for controlling multiple terminal windows in the same persistent session.

By default, terminating your SSH connection also terminates any remote terminal sessions started by that connection. If you use a terminal multiplexer, you can preserve those sessions for yourself and others to reuse. You can also manage more complex tasks from a single SSH connection, as a terminal multiplexer can provide browser-style tabs for each task, and even divide up your screen with multiple terminal sessions called “panes”.

In previous versions of Oracle Linux, you might have encountered a similar tool called screen, but in this tutorial you will explore tmux.


Upon completion of this Lab you will be able to:

What do you need?

The next section describes hands-on exercises you can perform in a lab environment to test tmux. To access the lab, click Launch lab next to the tutorial title.

(Hands-on Lab) Connect to the Compute Instance

Note: This step is specific to the Oracle provided free lab environment.

The Desktop environment will display before the instance(s) are ready. Deployment of this environment can take two to five minutes, depending on the number of resources and provisioning steps needed.

First, to access the lab compute instance(s), connect to the Oracle Cloud Console and copy the compute instance Public IP address.

  1. Sign in to Oracle Cloud Console, and select your Compartment.

  2. Click Instances.

  3. Copy the Public IP to a temporary location (such as a text file) on your computer.

    copy public ip

    To copy, highlight the IP address with the mouse and press Ctrl+C.

  4. Right-click the Virtual Desktop and select Open Terminal Here.

  5. Connect to the instance.


    Where <IP_ADDRESS_OF_COMPUTE_INSTANCE> is the IP address copied from the Oracle Cloud Console.

  6. Accept the ECDSA key fingerprint by typing yes at the prompt.

  7. You are now connected to the compute instance for this lab.

If the connection fails with the Permission denied (publickey,gssapi-keyex,gssapi-with-mic) message, wait a bit longer for the provisioning process to complete and try making the ssh connection again.

Install the tmux Terminal Multiplexer

Install the tmux package on your instance by using the package manager, as follows:

sudo dnf install -y tmux

Start and connect to a tmux session

Note: tmux sessions are not preserved between reboots, so they are best suited for persistent remote servers.

The tmux command rearranges your terminal window, with a green band running along the bottom that lists the currently active panes. By default, sessions and panes are ordered numerically, according to dynamically assigned ID numbers that count upwards from zero.

All tmux sessions are hosted in a background service, so that means you can reconnect to them if your connection times out, or if your user account has previously logged off.

  1. Start tmux without any parameters to create a new session and connect to it:
  1. List your currently open tmux sessions:
tmux ls
  1. Detach by pressing Ctrl+b, and then the d key.
  2. Reattach to your persistent tmux session:
tmux attach -t 0

You can run tmux ls from inside or outside tmux to verify which sessions are available for you to reopen.

Manage multiple tmux sessions

Note: You cannot create nested tmux sessions by default, so always ensure that you have detached from your current tmux session before attempting to create or connect to any other tmux sessions.

  1. Rename your existing session to oracle:
tmux rename-session -t 0 oracle
  1. Detach by pressing Ctrl+b, and then the d key.
  2. Create a new tmux session called oracletemp:
tmux new -t oracletemp
  1. Detach by pressing Ctrl+b, and then the d key.
  2. List your open sessions:
tmux ls
  1. Reconnect to the oracle session:
tmux attach -t oracle

multiple tmux sessions

Manage terminal window panes

Terminal window panes behave much like web browser tabs, where you can create, delete, and switch between them. Unlike a web browser, you must use keyboard shortcuts to perform those actions.

  1. Create a new terminal window by pressing Ctrl+b, and then the c key.
  2. Switch to the next window by pressing Ctrl+b, and then the n key. You should notice an asterisk move between each numbered tab as you switch.
  3. Switch to the previous window by pressing Ctrl+b, and then the p key.
  4. Switch to the second window by pressing Ctrl+b, and then then the 1 key.
  5. Close the second window by pressing Ctrl+b, and then the ampersand (&) key. Confirm the action.
  6. Rename the first window by pressing Ctrl+b, and then the comma (,) key. Set the new name to lab.

multiple panes in same tmux session

Manage split terminal window panes

You can split the current terminal window pane to suit your workflow. For example, you could input commands on one half of the terminal pane, and review the output for those commands on the other half.

split panes in same tmux session

Reconnect to a tmux session over SSH

  1. Detach by pressing Ctrl+b, and then the d key.
  2. Run the exit command to end the SSH connection.
  3. Press the up direction key, and then reuse the command you previously executed to start a new SSH connection:
  1. Reconnect to your tmux session:
tmux attach -t oracle

Terminate tmux sessions

  1. List your sessions:
tmux ls
  1. Detach by pressing Ctrl+b, and then the d key.
  2. Terminate your sessions.

More Learning Resources

Explore other labs on or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.