Intermediate LevelLinux Commands & SysAdmin
How do tmux and screen keep terminal sessions alive across SSH disconnects?
❓ Interview Prompt: Compare tmux vs screen, session persistence, detaching (Ctrl+B d), reattaching (tmux attach), and window splitting.
Terminal multiplexers ('tmux' and 'screen') run shell sessions inside persistent background processes on the server:
Benefit:
If your SSH network connection drops during a long-running migration or backup, the session inside tmux continues executing uninterrupted!
Essential tmux Commands:
•
'tmux new -s work': Start new named session.
•
'Ctrl+B d': Detach from active session.
•
'tmux attach -t work': Reattach to running background session.
Code Implementation Example
bash
# Start persistent tmux session named 'migration'
tmux new -s migration
# Detach from session: Press Ctrl+b then 'd'
# List running tmux sessions
tmux ls
# Reattach to session after SSH reconnect
tmux attach -t migration💡Managing persistent terminal sessions using tmux.
🎯 Interview Key Takeaway
Use tmux for long-running scripts over SSH to prevent task failure when network connections drop.
#tmux#screen#Terminal Multiplexer#Intermediate
Back to all Linux Commands & SysAdmin Questions→