0% found this document useful (0 votes)
4 views

tmux basics

tmux basics

Uploaded by

mmkreddy15
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

tmux basics

tmux basics

Uploaded by

mmkreddy15
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

**tmux** (Terminal Multiplexer) is a powerful command-line tool in Linux that

allows you to manage multiple terminal sessions within a single window. It is


particularly useful for remote server administration, as it keeps sessions running
even if your connection drops, ensuring uninterrupted processes.

### Key Features of tmux


1. **Session Management**:
- You can create, detach, and reattach to terminal sessions.
- Sessions persist in the background even if you disconnect from the server.

2. **Split Panes**:
- Divide the terminal window into multiple panes for parallel work.

3. **Window Management**:
- Create multiple windows (tabs) within a single tmux session.
- Navigate between windows easily.

4. **Customization**:
- Highly configurable via the `~/.tmux.conf` file for keybindings, colors, and
more.

5. **Scrollback History**:
- Access an extensive scrollback buffer to view past commands and outputs.

---

### Installing tmux


To install tmux on your Linux distribution:
- **Ubuntu/Debian**:
```bash
sudo apt update
sudo apt install tmux
```
- **CentOS/Red Hat**:
```bash
sudo yum install tmux
```
- **Fedora**:
```bash
sudo dnf install tmux
```

---

### Basic tmux Commands

#### Start a tmux Session:


```bash
tmux
```
- Starts a new tmux session.

#### Create a Named Session:


```bash
tmux new -s session_name
```
#### Detach from a Session:
```bash
Ctrl-b d
```

#### Reattach to a Detached Session:


```bash
tmux attach -t session_name
```

#### List All Sessions:


```bash
tmux list-sessions
```

#### Kill a Session:


```bash
tmux kill-session -t session_name
```

---

### Pane Management


- **Split Horizontally**:
`Ctrl-b %`
- **Split Vertically**:
`Ctrl-b "`
- **Switch Between Panes**:
`Ctrl-b o`
- **Resize Panes**:
`Ctrl-b` followed by arrow keys.

---

### Window Management


- **Create a New Window**:
`Ctrl-b c`
- **Switch Between Windows**:
`Ctrl-b n` (next) or `Ctrl-b p` (previous)
- **Rename Current Window**:
`Ctrl-b ,`

---

### Customize tmux (Optional)


Edit the `~/.tmux.conf` file to set custom configurations. Example:
```bash
# Set prefix to Ctrl-a
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Enable mouse support


set -g mouse on

# Set status bar colors


set -g status-bg black
set -g status-fg green
```
Apply changes:
```bash
tmux source-file ~/.tmux.conf
```

---

### Why Use tmux?


- Persistent sessions ensure long-running tasks aren't interrupted.
- Simplifies multitasking on terminal.
- Ideal for remote work over SSH.

Would you like examples of advanced usage or scripts?

You might also like