Tmux or not Tmux: it's an easy question

in #linux6 years ago

In a nutshell, tmux is a linux program that allows you to run terminals in the background and reconnect to them later or kill them. This is can be useful for running long scripts, such as updates, over unstable connections.
For example, if you start running updates on a Raspberry Pi from your phone and you lose connection, the Raspberry Pi might stop running the updates or continue without being able to see its progress. If you ran the updates under tmux, you could simply reconnect to the device and reattach to the backgrounded terminal.
This is one of many examples of using tmux. Here is a list of common tmux commands:

  • sudo apt install tmux
    *Installs tmux on Debian-like systems, like Raspbian, Ubuntu, or *

  • tmux
    Opens a new tmux shell. Useful for making a safe interactive shell

  • tmux attach
    Opens the last used terminal. Useful for quickly opening where you were last working.

  • In tmux: Ctl+b then Ctl+d
    Detaches the current terminal. Useful for leaving a terminal running in the background.

  • tmux new-session -s name "command"
    Makes a new window called "name" that immediately runs "command". Useful for keeping track of multiple windows.

  • tmux new-session -d -s name "command"
    Makes a new session called "name" running "command" and instantly detaches. Useful for writing a script that spawns a background process.

  • tmux ls
    Lists active sessions and their names. Useful for viewing active windows and their names or IDs.

  • tmux attach -t name
    Reopens the windows with the corresponding name or number. Useful for opening a specific window when you have multiple.

Written with StackEdit.

Coin Marketplace

STEEM 0.21
TRX 0.26
JST 0.040
BTC 101903.07
ETH 3676.99
USDT 1.00
SBD 3.21