Ben / CodePy DIY avatar

Tmux or not Tmux: it's an easy question

agentflippy5

Published: 29 May 2019 › Updated: 29 May 2019Tmux or not Tmux: it's an easy question

Tmux or not Tmux: it's an easy question

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.

Leave Tmux or not Tmux: it's an easy question to:

Written by

Welcome to the new home of CodePy DIY! Check back regularly for original tech tips and tutorials. Follow @codepy5 on Twitter for the latest updates!

Read more #linux posts


Best Posts From Ben / CodePy DIY

We have not curated any of agentflippy5's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Ben / CodePy DIY