Ubuntu 22.04 Tmux: Difference between revisions

From CompleteNoobs
Jump to navigation Jump to search
imported>AwesomO
m (Noob moved page Tmux to Ubuntu 22.04 Tmux)
 
(No difference)

Latest revision as of 18:50, 11 May 2023

tmux — terminal multiplexer

Basics

Description Quote from man page

tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

Tmux can do a number of things.

In this module we are just going to concentrate on solving the problem of something going wrong with are ssh connection.

If we lose are ssh terminal connection, processes we were running will be sent a SIGHUP signal.

SIGHUP

Lets go stright to a example of using tmux to solve this problem.

On are server lets run/start tmux.

tmux

that's it.

Now lets run a program and see what happens when we disconnect.

$EDITOR test-txt-file

Hello world
i am writing or doing something important.
i hope i dont disconnect and lose this

Now just close the terminal, do not save and/or exit the text editor, Just close the terminal.

Open another terminal and reconnect to your server.

Use the command tmux ls to list your tmux sessions.

tmux ls

My output:

0: 1 windows (created Mon Jun  1 06:41:43 2020) [140x14]

I am going to reconnect to my tmux session 0, with the command.

tmux attach -t 0

And thats its.

Tmux also solves the problem of your ssh session closing due to inactive

packet_write_wait: Connection to 192.248.157.27 port 22: Broken pipe

Note: you can run the same tmux session in more than one terminal at the same time. Open 3 terminal and log into server in each terminal
tmux attach -t 0
all will be updated in real time. If you exit tmux by typing exit in one terminal the tmux session will end and exit on all 3 terminals. If you dont want that just close terminal without typing exit

You do not need tmux installed on your local computer, just the computer(server) you are connecting to.

tmux is installed by default on ubuntu server 1804 but if you want to install it on your desktop or if its been removed from your server and want to reinstall apt install tmux

Scrolling on tmux

press CTRL+b followed by [ now you can scroll up and down with arrow keys. press q to quit scroll mode