惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
博客园 - 聂微东
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
小众软件
小众软件
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
量子位
月光博客
月光博客
博客园 - 【当耐特】
博客园 - 叶小钗

Ittavern.com

Wimage - Hosting Open-Source Image Uploader with Podman and external S3 Storage Switching from Hugo to picopaper Encryption using SSH Keys with age in Linux ETag in nginx - Simple Resource Caching Sending nginx Logs to Loki with Grafana Alloy How to: Cisco ISE backup to SFTP repository with public key authentication Dummy IP & MAC Addresses for Documentation & Sanitization Deploying ISSO Commenting System for Static Content using Docker Generate a Vanity v3 Hidden Service Onion Address with mkp224o ssh-audit Primer - Audit your SSH Server mtr - More Detailed Traceroute - Network Troubleshooting My Personal Backup Strategy - August 2024 iperf3 - User Authentication with Password and RSA Public Keypair Adding a trash can to Linux with trash-cli Bandwidth Measurement using netcat on Linux Getting started with rsync - Comprehensive Guide Cron Jobs on Linux - Comprehensive Guide with Examples SSH Server Hardening Guide v2 Port Knocking with knockd and Linux - Server Hardening Getting started with rclone - Data transmission Getting started with dig - DNS troubleshooting Getting started with Fail2Ban on Linux Getting started with netcat on Linux with examples URL explained - The Fundamentals Troubleshooting Asking The Right Questions Create tmux layouts using bash scripts Getting started with tcpdump - Ittavern.com Curl on Linux - Reference Guide Getting started with nmap scripts My Offsite Backup - March 2023
Getting started with tmux - Ittavern.com
2022-11-21 · via Ittavern.com

Tmux is a terminal multiplexer. It allows you to work with multiple terminal sessions at once.

Installation #

It is easy to install, and there are many guides already out there, so I won't cover it in this blog post.

Tmux terminology #

So, let us start with the basics.

tmux server (programm) > session > window > pane

The tmux server starts after running tmux. You can work on the attached sessions or detach them so they run in the background. Every server can have multiple sessions, every session can have multiple windows, and we can split a window into multiple panes. The pane is a normal terminal window at the end.

tmux-overview

There are a lot of use cases for it. Tmux makes is easy to separate projects in different windows or sessions.

The prefix or lead and meta-key #

The default prefix (or sometimes called 'lead') is CTRL + b (or C-b) and it is usually the start of a tmux shortcut or to use a tmux command. When you see something like: Prefix + c, press CTRL + b, and then c. I prefer CTRL + s for example. I'll explain how to change it in the next section.

As a side note: you'll find some shortcuts with an M in them. This is the meta-key. It is ALT for Linux, I think CMD in MacOS, and sometimes even ESC. The meta-key is rarely used, but worth looking it up.

The config file #

You can temporarily change your tmux config by entering the setting:

Prefix + :set -g prefix C-s

This would change the Prefix as we described it before. If you want to make changes permanently, edit the config file. On Linux, the config file is usually in the home directory of the user ~/.tmux.conf. If there is no config file, simply create it, and restart tmux - or reload it (will show in the end of this section). Just put set -g prefix C-s into the config file and tmux will use it after the restart.

There are many ways to customize tmux. Some examples: Vim-like bindings for pane movements, enabling mouse support, setting keyboard shortcuts, and so on.

The easiest way to reload the config file after changes is to use the following tmux command: Prefix + :source-file ~/.tmux.conf (change the path accordingly).

Working with panes #

As mentioned before, you can split a window in multiple panes. You can split the window vertically or horizontally as you wish and change it as much as you want. I won't cover everything in this post, but I'll show you the basics.

Split horizontally:
Prefix + %
Split vertically:
Prefix + "
Move to another pane:
Prefix + ARROW KEY
Convert the current pane into a new window:
Prefix + !
Close current pane:
Prefix + x

There are shortcuts for resizing, moving panes around, and so on, but those aren't that important for this primer.

Side note: I just wrote a separate post about sending input to all panes within a window. Feel free to check it out here.

Working with windows #

I prefer to separate my projects with windows instead of sessions, but that is my personal preference.

Create a new window:
Prefix + c
Rename current window:
Prefix + ,
Close current window:
Prefix + &
Switch to next window:
Prefix + n
Switch to previous window:
Prefix + p
Switch to window by number:
Prefix + 0-9

Working with sessions #

Let me start with a shortcut that I just learned recently.

Overview:
Prefix + w

This gives you a quick overview of all sessions and windows and lets you switch quickly.

Show all sessions:
tmux ls
Prefix + s
Create new session:
tmux new -s new-session
:new -s new-session
Rename session:
Prefix + $
Kill the session:
:kill-session
Detach session (will be active in the background):
Prefix + d
Close a session:
tmux kill-session -t old-session
Attach session:
tmux attach -t old-session
Move to next session:
Prefix + )
Move to previous session:
Prefix + (

Conclusion

This post hopefully will help you to get started with tmux. I'll cover more topics and features of tmux in the future.

Any notes or questions? - Feel free to reach out.