Stories
Slash Boxes
Comments

SoylentNews is people

posted by Fnord666 on Wednesday September 25 2019, @03:43AM   Printer-friendly
from the multitasking dept.

Arthur T Knackerbracket has found the following story:

Tmux is a very powerful terminal multiplexer which is extremely useful especially when you are using the remote server via SSH.

If we want to do multiple tasks simultaneously on the remote server, usually we have to two ways to do it. We could SSH into the remote server and run everything in the background with an ‘&’ at the end of each terminal command. This is problematic if you want to monitor the process of each task. We could also open multiple windows, SSH into the remote server for each window, and run one task for each window. This is good for monitoring all the tasks, but the shortcoming is that you would have to type your SSH login information for each of the windows you opened. Sometimes it is also hard to find which window is doing which task if there are too many windows opened.

Tmux allows the user to create multiple sessions and each session could have multiple terminals. The user would be able to control multiple tasks in multiple windows via Tmux. No more multiple SSH logins anymore. However, Tmux is not very friendly to beginners because you would have to memorize a series of commands required for controlling Tmux. Although Tmux is much useful than a terminal emulator such as Gnome Terminator, many users would just like to use Tmux as a multi-window terminal emulator. However, Tmux does not memorize user settings such as pane layouts, so every time after reboot or restart the Tmux server, all of the user settings will be gone.

In this short tutorial, I am going through some of the basic concepts and commands for Tmux, and how to use a Tmux plugin, which is called Tmux Resurrect, to restore Tmux environment after reboot or Tmux server restart.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 3, Interesting) by Marand on Thursday September 26 2019, @02:00AM

    by Marand (1081) on Thursday September 26 2019, @02:00AM (#898897) Journal

    It is great for long running tasks if you're concerned about dodgy connections

    Using Mosh [mosh.org] instead of ssh is a better choice for dodgy connections on a single machine. It negotiates the connection with ssh to start, but once set up, everything's over UDP and resilient against connectivity losses, including swapping to a completely different connection, such as switching to/from wifi on a device with a mobile radio.

    The strength of screen or tmux is maintaining a single session across multiple devices. And for that, tmux wins over screen, with a better handling of sessions and multiple attached clients. (A blogpost detailing some of the differences [wtanaka.com].) Tmux manages multiple sessions in a single instance, letting clients hop over from one session to another easily, move or clone windows across sessions, etc. It also provides a keybind that brings up a useful interactive tree-view of all running sessions, windows, and panes, including a live preview of the contents of each, which I've found extremely helpful with managing multiple long-running tmux sessions. Its improvements over screen make it much more useful across multiple systems and as a terminal "window manager".

    ctrl + a changing to ctrl + b would mess my head up for a while too.

    No need, you can just change the keybind and use it like you always have. I absolutely hate ^B as the prefix and immediately changed it back to ^A for ergonomic reasons. Put "set-option -g prefix C-a" into ~/.tmux.conf and keep the muscle memory like I did. If you ever need to send ^A, you can also add "bind-key C-a send-prefix" so that ^A ^A will pass a single ^A through to the shell.

    That said, I'm now seriously considering doing something mentioned in the comments of that screen/tmux differences page: mapping the command prefix to backtick instead of a ctrl key. I don't use it much in shells because I use fish, which uses parentheses instead of backticks for command substitution, so it might be a lot more convenient.

    Starting Score:    1  point
    Moderation   +1  
       Interesting=1, Total=1
    Extra 'Interesting' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3