8 ms·
If you aren't using tmux or screen, you probably should be, especially over SSH sessions. They allow you to have multiple consoles open and switch between them,
by jodrellblank 8y ago
If you aren't using tmux or screen, you probably should be, especially over SSH sessions. They allow you to have multiple consoles open and switch between them, split window, and disconnect from SSH and then reconnect with all your things still open and running (as long as the server stayed running).
- dllthomas 8y agoI use some scripts around screen (and tmux would do the job at least as well, just haven't had reason enough to switch) to manage contexts for my shells. The key is that that process will be the parent of any shells I spawn in contained windows, and so if I set an environment variable (I use SESSION) before kicking off screen it will be inherited, and visible in my bashrc. This lets me set up a lot of context specific things - path and functions and aliases - but the single best thing about it is a separate bash history per context.
- berbec 8y agoI have a EC2 instance who's main purpose is to run a screen session. I ssh to my EC2, and load that screen. I have every server I manage in it's own "window" inside this screen. I run screen on each of these machines, so I can hop between inner and outer screens. The main screen instance is started with: screen -S outer_screen I then create a screen session for that EC2 with screen -S inner_screen I pop open new screens with this handy command: screen -S outer_screen -X screen -t newmachine ssh user@newserver.example.com
- spondyl 8y agoAs someone who hasn't invested much time into tmux/screen, what are the benefits of it over just using eg; multiple terminal tabsn or using the terminal's built in split windowing? I'm sure there's probably a benefit but I dunno what it is
- weavie 8y agoIt persists your session, so if you get disconnected you can just log in again and 'tmux attach' to resume from where you left off. Any long running commands will still be running.
- cerberusss 8y agoBoth tmux and screen allow you to attach/detach. Thus you can log off, and you can pick up your session later. For example, yesterday I logged into a Linux server at DigitalOcean via SSH. I ran tmux, started a long-running job, detached the session. I closed my laptop to go home for lunch. When I returned at my desk, I logged into the server and reattached the tmux session so I could see the results.
- jodrellblank 8y agoIf it's all on one device and no networking, I don't know of any great benefit. But if you sometimes connect to the machine remotely then Tmux allows you to pick up an existing session, e.g. You open tmux on your desktop, open some command line things, then walk away and pull out your laptop or desktop, SSH to your computer, "tmux attach" and have the same session open - and it's open on both devices, both seeing the same updates at the same time, like a terminal-vnc. And you can variously use them to allow two separate users to share the same session, either one controlling and others read-only, or multiple-editing ( https://unix.stackexchange.com/questions/2523/what-are-other-ways-to-share-a-tmux-session-between-two-users https://unix.stackexchange.com/questions/2523/what-are-other... )
- pjungwir 8y agoI agree with everyone else that it's great on remote systems, but the reason I use it locally too is because I can set up all a project's "tabs" with just one command. I have dozen-line scripts for each client/project that will either create or attach to a tmux session, and when creating set up all the windows how I want: setting their names, cd'ing, opening psql, tailing a log, changing the bottom color (green for development, yellow for staging, red for production), etc. For Rails work I typically have separate windows for models, controllers, views, stylesheets, and javascripts. It makes it really easy to get started after a reboot, or just hide projects for a while and bring them back quickly.
- em-bee 8y agooccasionally i need to restart the GUI. using tmux locally is very helpful for that. also sometimes i log into my workstation from remote, like when i am travelling. it's nice to be able to access the running session.
- Lio 8y agoOne useful reason to use it over a terminal is portability. If you're happy mostly working in the terminal then tmux will be the same on every OS your work on even if your favourite terminal isn't available.