Today I Learned - Rocky Kev

TIL about Tmux and persistent terminals

POSTED ON:

TAGS:

I bought a Raspberry Pi 4 a few months ago and struggled to find something to do with it.

I learned recently of a cool way to farm Steam Cards.
But the thing about when you disconnect from a remote computer, the command gets killed.
To explain in a different way:

  1. You ssh into your raspberry pi
  2. You run a command.
  3. You watch the command go, and it continues to run.
  4. You decide to close the terminal (and kill the connection)
  5. The command stops too.

But you want the command to run non-stop. WTH?

To solve that, you'll use something like Tmux.

Tmux is a terminal multiplexer an alternative to GNU Screen . In other words, it means that you can start a Tmux session and then open multiple windows inside that session. Each window occupies the entire screen and can be split into rectangular panes.

With Tmux you can easily switch between multiple programs in one terminal, detach them and reattach them to a different terminal.

Tmux sessions are persistent, which means that programs running in Tmux will continue to run even if you get disconnected.

Via the Documentation: https://linuxize.com/post/getting-started-with-tmux/

To install:

$ sudo apt install tmux

Once it's up and running:

To check if there's any windows open:

tmux ls

To start a new session:

tmux new -s session_name_here

To detach from a current session:

ctrl + b, then d

To kill a session:

tmux kill-session -t session_name_here

To return to a session:

tmux a -t session_name_here

Via the Tmux Cheatsheet: https://tmuxcheatsheet.com/


Related TILs

Tagged:

TIL Trovald's Magic Numbers

These magic numbers are intended to safeguard against a typo or potential bit flips in the syscall number. Since reboot is a destructive and non-syncing operation, it's important to make absolutely sure that it isn't called accidentally due to a typo, a misbehaving program, or memory error

TIL linux user groups

UID 0 is reserved for root user. UID 1-99 is reserved for other predefined accounts. UID 100-999 is reserved for system accounts. Also notice that user accounts tend to start at 1000. UID above 999 are for normal user accounts.

TIL How to determine what security group you're in

These commands will help you figure out what group you're in, and if you belong to the group that can modify files.