“You are logged into your remote server via SSH and happily plucking along at your keyboard and then it happens. Suddenly, the characters stop moving and then you get the dreaded ‘Connection Closed’ message. You have just lost your session. You were halfway through some task and now you have to start over. Ugh. Well you can prevent this from happening by using screen. The Linux screen tool can not only save you from disconnection disasters, but it also can increase your productivity by using multiple windows within one SSH session. I use this tool all of the time in our server management work.” An older tutorial, and even though I have little to no knowledge about screen, I know one thing: lots of people swear by it.
I swear by it. It’s a _really_ powerful tool and easy to use if you just want basic functionality.
But they are both awesome tools. I always recommend them to people new to cli.
tmux really is better… I’ve used it extensively to keep the sessions on my sparcstation open even if the ssh connection craps out.
It would be nice if it were a bit more integrated into ssh so that it could resume connections automatic ie when on a cellular or intermittent wifi connection.
The keyboard usage on tmux seems a bit more polished to me I suppose thats the main thing.
Edited 2012-08-31 01:03 UTC
I do this with screen, but I’m sure the same thing would probably work with tmux. Here’s how, http://taint.org/wk/RemoteLoginAutoScreen
edit:
Someone already seems to have modified the above to work with tmux, http://william.shallum.net/random-notes/automatically-start-tmux-on…
Edited 2012-08-31 02:11 UTC
http://mosh.mit.edu/
That might be exactly what you’re looking for.
If you like screen you might want to have a look at tmux. It’s like screen only with a modern design and actively maintained. I find it to work much better in general.
I’m another Tmux user as well.
Used to run GNU Screen heavily, then discovered Tmux and never looked back.
As a rails developer screen is a mandatory part of my toolkit. My only complaint is that I cannot seem to name the screens, so I have to remember which number is the server, console, vi session, etc… Does tmux have naming?
Yes!
From http://www.openbsd.org/cgi-bin/man.cgi?query=tmux&sektion=1
, Rename the current window.
Yes, it does but tmux also shows the current command next to each window number in the status bar.
screen can already do what you want. Enter C-a A to give the current window a name. Enter C-a ‘ (quote) to prompt for a window name to switch to. Enter C-a ” (double quote) to list all the screen names/numbers.
Yes, RMS has tired everyone out by arguing that people could say GNU/Linux, but come on. It’s not the Linux screen tool.
It is GNU Screen, originally done on the BSD platform and integrated with the GNU project in 1990, before Linus released his first kernel. People have been using it for more than two decades on all kinds of Unix flavors, as well as on Windows and OSX.
Linux is great, but it’s just a kernel, and that kernel was designed originally to run all the cool GNU and BSD code that already existed.
If that kind of thing pisses you off, you probably need to get out more. Seriously. Especially if you didn’t even write the f**king thing.
No, he’s absolutely correct. The name of the software is “GNU screen”, not “screen”. So while the whole GNU/Linux issue is debatable, calling “GNU screen” “Linux screen” is miss-attribution and wrong.
Pardon me for the intrusion, but from were I stand it would appear that you are the one who’s pissed off?
The O.P. is right and I was disappointed to see that, at least initially, he had been modded down just for putting things into perspective. And yes, I used (or rather, had to use) “screen” in the very early 90s… on SCO UNIX, no less! 😉
Oh, and “screen” was great for TIA, aka The Internet Adapter (http://en.wikipedia.org/wiki/The_Internet_Adapter). Anyone remember that?
RT.
Edited 2012-08-31 07:48 UTC
Excellent tool. As a sysadm, I used to use this all the time for remote connections, esp. for night work. These days connection reliability is so improved it’s not the issue it once was.
Actually, it is more a problem now than it has ever been before (maybe except for times of dial-up connections). I tend to work mostly on laptops, and switching between networks, suspending/waking up the machine, or simply losing a wireless connection happens all the time, often on purpose. Generally, relying on a TCP connection for holding the application state is a poor design decision these days.
BTW, this is also the main reason I don’t use X for remote work nowadays. It was simply designed for a different use case (a server with fixed terminals). Another reason is that X with its networking performance issues, and without properly configured NFS/NIS, forwarded sound recording/playback, DBUS services, printers, CD-ROMs, card readers etc., is no longer network transparent but it still pretends to be (by mixing up local and remote windows).
As far as I’ve seen, the primary use of Screen is to run TinyFugue while you’re at work.
12 or so years ago, I got introduced to Screen because I wanted to leave my nickname connected to IRC 24/7. Screened BitchX sessions, Eggdrop bots, riding netsplits to wage channel wars. Fun days.
I switched from GNU Screen to tmux a few years back because I use vertical splits quite a lot and Screen didn’t have that feature built in yet.
The first two things that I install on a new server are tmux and Vim.
Same for me, basically. Switched to tmux after years with screen. Was much easier to get into; partly due to prior experience with screen, mostly because it had clear documentation and didn’t require me to be fluent in Klingon to configure it.
Another vote for tmux as well.
When I started out on the Internet it was all text and UNIX prompts for me. So when I discovered screen it was great.
TinyFugue
Pine (private)
Pine (work)
Tin
ircii
& a couple of shells to different servers.
My ‘screen’ ran at work, but as it was such a great tool more and more coworkers started using it causing system admins to get annoyed and we had to move server a few times. If you didn’t a kill script would kill you (well, your screen session).
hardstatus alwayslastline
hardstatus string ‘%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR} (%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}] %{=b C}[ %m/%d %c ]%{W}’
An then, you are good to go
Isn’t screen obsolete now that we have GUIs everywhere? It’s much easier to just open a new tab in Konsole (or your favourite terminal app) and make another SSH connection. If you are using Windows you just open up another putty window.
Aside from terminals not having support for detaching and re-attaching sessions the way screen and tmux do, my responsive, lightweight terminals of choice (uxterm and urxvt) don’t always do tabs.
(urxvt does, but it’s basically a Perl script that does textual tabs in a manner inferior to screen or tmux)
Also, terminal tabs are less than ideal if you have to open a new SSH connection every time you Ctrl+Shift+T rather than just running screen on the remote system and doing Ctrl+a c.
No.
Pressing Ctrl-b+c is a lot quicker and easier than opening a new tab and making a new connection. Not to mention that the screen/tmux session survives disconnects.
Say you run apt/yum from command line, using a konsole tab or putty and suddenly, gasp, you lose connection / your X session dies / SSH dies, etc. Recovery, if possible, will be -very- painful.
I never, never, never, never run anything destructive from a normal command prompt – I always use screen.
– Gilboa
I hear it’s pretty good.
mosh is a replacement for ssh, not for tmux/screen. Well, it’s an SSH replacement that, uh, uses SSH to work.
Started using screen after an OSNews article/link a few years ago, now I find it absolutely indispensable. Though it can get a bit disorienting sometimes, especially when working via remote desktop session running PuttyCM, with 3 or 4 tabs/connections open, each with at least 2 or 3 screens open.
My favourite trick with screen is using my smartphone to monitor a long-running process (E.g. rsync’ing a few GB of data from one server to another). I just start the process in a screen session via my desktop/laptop, then connect to the same account through SSH, and use “screen -x [session id]” to connect to the same session. The same strategy also works well for doing remote support/training via SSH (and much easier to setup that most desktop-sharing solutions I’ve used).
I prefer to use TMUX. It’s much more responsive, cleaner and generally better. Screen is kinda sluggish and old.
I use Byobu
http://en.wikipedia.org/wiki/Byobu_(software)
Install and try it now, in 5 minutes you’ll have forgotten the name ;-).
(copy paste the url, there is an osnews bug where last paren is stripped)
Edited 2012-09-02 05:57 UTC