Open In App

How to Set tmux for Opening Specified Windows at Startup?

Last Updated : 16 Nov, 2023
Like Article

In Linux to open specific windows at startup, we can configure the tmux utility. We need to modify the tmux configuration file in the system which will allow us to create windows and also specify the layout. To make sure that windows open when tmux starts, we can include the special command at the end of the configuration which will ensure the proper opening of windows. In this article, we will see a practical demonstration of setting up tmux to open specified windows at startup.

What is Tmux?

Tmux, or “terminal multiplexer“, is a command-line tool that allows you to manage multiple terminal sessions within a single window. It enables you to split your terminal into panes, each displaying its command line, and create multiple windows with different tasks or programs. Tmux is particularly useful for system administrators and developers working on remote servers or managing complex projects. It provides a persistent environment, allowing you to detach from a session, log out, and later reattach to the same session, ensuring your work continues uninterrupted. With its features, Tmux enhances productivity by providing an efficient way to organize and navigate your command-line interface.

How to set Tmux to open specified Windows at Startup?

In this section, we will perform step-by-step execution of setting Temux to open specified WIndows at Startup. So follow the below steps and execute the commands to open Windows efficiently without encountering any issues.

Step 1: Open the Terminal

Firstly, we need to launch the terminal on our Ubuntu system, we can launch by using the Application Menu or by using the Keybaord Shortcult as “CTRL + ALT + T”.

Open the Terminal

Open the Terminal

Step 2: Install tmux

After the successful launching of the terminal, we need to install the tmux utility by using apt manager. Execute the below command in the terminal for successful installation of tmux.

sudo apt-get install tmux
Install tmux

Install tmux

Step 3: Create a tmux startup script

Then, create a new file for the tmux startup script, for example, We can use the touch command to create the script file.

Create a tmux startup script

Create a tmux startup script

Step 4: Edit the startup script

After creating the file, we need to open the newly created tmux startup script in a text editor, for instance, nano editor.

Edit the startup script

Edit the startup script

Step 5: Add window specifications to the startup script

Then we need to populate the startup script with the content from the provided tmux startup script, adjusting commands and window names as needed.


# Start a new detached tmux session named GFG_Session
tmux new-session -d -s GFG_Session

# Create the first window named GFG_Overview with an 'echo' command
tmux send-keys -t GFG_Session "echo 'Welcome to GeeksforGeeks!'" C-m

# Split the first window horizontally and send a 'pwd' command to the new pane
tmux split-window -h -t GFG_Session "pwd" C-m

# Create a new window named GFG_Code with an 'ls' command
tmux new-window -t GFG_Session "ls" C-m

# Split the GFG_Code window vertically and send an 'echo' command to the new pane
tmux split-window -v -t GFG_Session "echo 'This is the code directory'" C-m

# Create a new window named GFG_Terminal with an 'ls' command
tmux new-window -t GFG_Session "ls" C-m

# Attach to the tmux session
tmux attach-session -t GFG_Session
Add window specifications to the startup script

Add window specifications to the startup script

Step 6: Save and exit

Save the changes made in the text editor (nano) and exit to finalize the tmux configuration. We can press Ctrl + X, then Y, then Enter to Save and Exit from Editor.

Save and exit

Save and exit

Step 7: Make the script executable

Now, by using the chmod command we need to make the script executable to run it.

chmod +x
Making script executable

Making script executable

Step 8: Run the tmux startup script

Now, by using the below command we need to execute the script. This script will create a tmux session with four windows, each with specific commands.

Script Execution

Script Execution

Step 9: View Other Windows

By using the keyboard shortcut Ctrl + b, we can navigate to opened panes in the terminal. We need to press the Ctrl + b shortcut along with the window number.

For example: Press Ctrl+b, then 0 to switch to the “GFG_Overview” window.

Switching to another window

Switching to another window

Press Ctrl+b, then 1 to switch to the “GFG_Code” window.

Switching to another Window

Switching to another Window


In conclusion, setting tmux to open specified windows at startup involves defining a script or configuration file to automate the creation of windows and panes with predefined commands. Utilizing commands like new-session, new-window, and send-keys, users can customize the layout and content of each window. This approach allows for a seamless and efficient setup, ensuring that desired windows are automatically opened when tmux is initiated, streamlining the workflow for a more organized and productive terminal environment.

Similar Reads

How to write a shell script that starts tmux session, and then runs a ruby script
Scripts are important for streamlining workflows and automating tasks. One such way to streamline workflow is by using Tmux [Terminal Multiplexer]. When used along with shell scripts we will be able to automatically commence a Tmux session and perform certain tasks. In this article, we shall see how to use a shell script that will automatically sta
4 min read
Working with tmux session
tmux is software application providing a command line interface and also allowing user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. While you work with Amazon Web Services(or any other cloud computing platform like Google Cloud Platform or Microsoft Azure) it helps to create a separate se
2 min read
How to Use ‘Tmux Terminal’ to Access Multiple Terminals Inside a Single Console
tmux, or Terminal Multiplexer is a command-line tool for managing multiple terminal sessions in one window. It's beneficial for developers and system administrators, offering features like splitting the terminal into panes, creating sessions with windows and panes, customization, scripting, and remote access. Users can organize tasks efficiently, c
4 min read
Tmux in Linux
Tmux, short for "terminal multiplexer," is a powerful command-line tool in Linux that enables users to manage multiple terminal sessions within a single window. It allows for the creation and manipulation of multiple panes and windows, facilitating multitasking and efficient workflow organization. Tmux is particularly useful for remote sessions and
6 min read
How to Create tmux Session with a Script
Managing terminal sessions efficiently is crucial for developers and system administrators. tmux (short for terminal multiplexer) is a powerful tool that allows you to create and manage multiple terminal sessions within a single window. It is particularly useful for working on remote servers or handling long-running processes. In this article, we w
6 min read
Stealth Startup : Meaning, Types, Working, Benefits and Drawbacks
What is a Stealth Startup?A stealth startup refers to an agency that is in "stealth mode," which means it operates in a secretive or personal manner, maintaining information about its products, offerings, or enterprise version hidden from the public and frequently from potential competitors. The purpose of operating in stealth mode is generally to
17 min read
Opening Stock : Meaning, Types, Formula & Examples
What is Opening Stock? Opening Stock is defined as the amount or quantity of goods available to the business for sale at the beginning of the accounting period. The opening stock for the current period is usually derived from the stock available after the conclusion of sales from the last accounting period, based on the nature of the business. It i
7 min read
How to disable superfetch in windows 10 or windows 11?
Windows Vista introduced the Superfetch (SysMain) capability, which is still a part of the Windows operating system. It is a built-in service designed to speed up startup times and enhance performance by preloading frequently used apps in RAM. It was, however, primarily developed for older PCs. For contemporary PCs running Windows 10 and Windows 11
4 min read
How to Open Windows PowerShell as an Admin in Windows 11?
Windows Powershell is a powerful command-line shell and scripting language devised for administrators and professionals. PowerShell with administrative privileges in Windows 11 makes it possible to carry out tasks with superior permissions. This article will discuss several ways of opening Windows PowerShell as admin. What is Windows PowerShell?The
4 min read
Shell Script to create a compressed archive of the specified directory
An archive is a simple process of storing a group of files or folders into one file. Sometimes we may need to create a compressed archive out of a single folder so that we can share it with others or for something else. In Linux, to ease the task, we can create a shell script to automate the process of creating an archive by simply providing the fo
3 min read