How to Keep Remote Servers Running With Tmux for Days Even if You Close Your Terminal
Tmux is a powerful terminal multiplexer that allows you to manage multiple terminal sessions within a single window. This capability is incredibly useful for keeping remote servers running for days, even if you close your terminal. In this cheat sheet, we’ll cover essential commands and keyboard shortcuts to help you get started with Tmux.
Why Tmux is Useful
- Run and manage multiple terminal sessions within a single window.
- Easily switch between them using keyboard shortcuts.
- Detach from a session and reattach later to pick up right where you left off.
- Keep processes running even after you close your terminal, ensuring uninterrupted server tasks.
Installation
Ubuntu
|
|
Creating and Managing Sessions
Create a New Session
|
|
To attach to an existing session:
|
|
To kill a session:
|
|
To list all sessions:
|
|
To exit a session:
|
|
Keyboard Shortcuts
Note: To use these shortcuts, press Ctrl+b first, release it, and then press the corresponding key.
|
|
Customizing Tmux: Mouse Scrolling, Status Bar, and More
You can customize Tmux by editing the configuration file located at ~/.tmux.conf. Here are a few examples of customizations:
|
|
These are just a few examples of customizations you can make to your Tmux configuration. Feel free to explore the Tmux manual and experiment with different settings to suit your preferences.
Remember to save the changes to your ~/.tmux.conf file and restart your Tmux session for the new settings to take effect.
With these essential commands, keyboard shortcuts, and customization options, you’ll be able to enhance your productivity and efficiently manage multiple terminal sessions using Tmux. This approach ensures that your remote servers and processes can continue running seamlessly, even if you disconnect from your terminal.
Enjoy using Tmux!