Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

GNU Screen: an introduction and beginner's tutorial

By jeduthun in Technology
Wed Mar 10, 2004 at 07:23:33 PM EST
Tags: Software (all tags)

Most modern Unix-based operating systems (e.g. Linux, MacOS X, and BSD) come with a little console-mode utility called GNU Screen. It's a powerful tool in the hands of the console warrior, a veritable Swiss Army knife of text-mode human-computer interaction.

This utility, despite its considerable usefulness, goes unused by a great many people. Why is this? Few people even know it's there, and those that do rarely understand the problem it solves. In this article, I will explain what screen does for you, and provide a simple set of instructions for accomplishing basic tasks using screen. My audience is those that are skilled with the command line but who have little or no experience with screen itself.

What screen does

Screen is best described as a terminal multiplexer. Using it, you can run any number of console-based applications--interactive command shells, curses-based applications, text editors, etc.--within a single terminal. The desire to do this is what gets most people hooked on screen. I used to start a half-dozen terminal emulators when I logged into my machine: I wanted one to read my email, one to edit my code, one to compile my code, one for my newsreader, one for a shell into my web host, and so on. Now I start one terminal emulator, and run screen in it. Problem solved.

The other main cool feature of screen is its ability to decouple the terminal emulator from the running programs. This means that you can use screen to keep programs running after you accidentally close the terminal emulator, or even after you log out, and later resume right where you were. It means that the idea of a "session" in which you are running a number of console programs is a free-floating entity that you can bind to any terminal anywhere, or no terminal at all if you want.

Getting started with screen: launching and switching between programs

Start screen just by typing screen at your favorite command shell prompt. You'll probably be greeted by a welcome message. Dismiss this and you'll have with an empty terminal containing a shell prompt, which is pretty much what you had before you started screen. What happened?

Every program running under screen runs in a window, and every window is identified by a unique number. Screen made a new window, numbered it 0, and started a command shell inside it. Type something in your new window so you'll be able to recognize it when you switch to it later.

Now make another window; this will be window 1. To do this, type C-a c; that is, type Ctrl-a and then type c (mnemonic: create window).

Now that you have two windows, try switching between them. To do this, type C-a C-a, which will switch you to whichever window you were using before the current one. Some other useful window switching methods, which you'll need if you plan to run more than two programs:

  1. Use C-a n and C-a p to switch to the next or previous window in the list, by number.
  2. Use C-a N, where N is a number from 0 to 9, to switch to the corresponding window.
  3. Use C-a " to get a full-screen list of windows. You can navigate this list with the arrow keys (or vi-style, with j and k), and pick a window to activate by pressing Enter when it's highlighted. C-a w will give you a small, non-interactive list of windows.

When you're using a window, type C-a A to give it a name. This name will be used in the window listing, and will help you remember what you're doing in each window when you start using a lot of windows.

Exiting the last program in a window will cause the window to disappear. You can also kill misbehaving programs with C-a K.

Detaching and reattaching: the magic of terminal decoupling

If you did the exercise above, you have successfully created a screen session. You can detach from this session by pressing C-a d. You can also detach just by closing the terminal emulator that contains the session. However, keep in mind that neither of these actually end your session. All they do is unbind your session from the current terminal. All of the programs you started running within screen are still running. Really.

Try it: just close whatever terminal emulator you were using to do the exercise above. Then log out, and log back in, if you desire. Start up a new terminal emulator, and type screen -r (the R, obviously, stands for "reattach"). You'll be right back where you were when you detached.

You can probably imagine a lot of good uses for this. You can start all your favorite console programs once and just leave them running in a persistent screen session. Some people have "screen uptimes" of several months.

One other good use for the detach and reattach is as a console-mode "remote desktop" feature. You can detach from a screen session at work, shell into the machine from home, and reattach. Very, very handy. With a bit of extra work, you can even have a number of terminals all attached to the same session--great for collaborative efforts and meetings.

Copying, pasting, and the scrollback buffer

Screen remembers a configurable number of scrollback lines, and you'll need them because you won't be able to use your terminal emulator's scroll features while running screen. You can access the scrollback buffer by entering "copy mode", which is accomplished by typing C-a [. You can mark text anywhere in the scrollback buffer and paste it with C-a ]. Screen is also capable of logging to files, but that's beyond the scope of this tutorial.

Monitoring for silence and activity

One of the disadvantages of running a bunch of programs within screen is that you can't keep an eye on all of them at the same time, since in general you can only see one at once. (Actually, you can split the screen and look at more than one at a time, but that's an advanced topic beyond the scope of this tutorial.) To help mitigate this problem, Screen has features that allow you to monitor a window for silence--useful for knowing when a compile has finished, for example--or activity--useful for knowing when someone is finally talking on your favorite IRC channel, for example.

To start or stop monitoring the current window for 30 seconds of silence, type C-a _; to start or stop monitoring a window for activity, type C-a M.

Making it go away

As you've seen from the section on detaching and reattaching, screen is not easy to kill. You can't just close its containing terminal. (Actually, you can, but then all those processes are still running on your system, ready to be reattached.) There's no "quit" key in the How do you fully exit screen?

To my knowledge, the only way to do this nicely (i.e. without sending nasty signals to processes that don't deserve it) is to close each of your screen windows. Exit whatever programs or shells each is running, and they will go away. When the last program running inside screen is exited, screen itself will go away.

Other stuff

Screen does much, much more than I've described above, but it's enough to get you started. You can type C-a ? for a terse list of commands available while you're in screen. The screen man page has a wealth of info, too. And here are some web resources, if you have questions:

Yahoo GNU Screen Group
A fairly high-traffic mailing list for screen. Many knowledgable people hang out here.

Sven Guckes' Screen Page
Another overview page; a good deal more terse than this one.

The official screen home page
No explanation needed here. The page is surprising sparse on details.

The screen man page
Nicely formatted and separated by section. Good reference. Be sure to check out the sections on using .screenrc to customize screen.

Screen FAQ
Not for newbies, but a good resource to dig into for troubleshooting.


Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure


What is your experience with GNU Screen?
o I've never heard of it 18%
o Heard of it, never used it 29%
o Use it sometimes 20%
o Use it a lot 26%
o I don't like console programs 4%

Votes: 181
Results | Other Polls

Related Links
o Yahoo
o GNU Screen
o Yahoo GNU Screen Group
o Sven Guckes' Screen Page
o The official screen home page
o The screen man page
o Screen FAQ
o Also by jeduthun

Display: Sort:
GNU Screen: an introduction and beginner's tutorial | 196 comments (166 topical, 30 editorial, 5 hidden)
Comparing and contrasting? (2.50 / 8) (#1)
by Blarney on Tue Mar 09, 2004 at 04:15:41 PM EST

How does GNU Screen compare to, for example, the butt-simple terminal switching of ALT-Fn or CNTRL-ALT-Fn that Linux has? I find it much easier to switch screens that way when I'm working in text mode.

hmm... (2.76 / 13) (#2)
by Burning Straw Man on Tue Mar 09, 2004 at 04:20:24 PM EST

let's imagine, for a moment, that you're not sitting in front of your UNIX workstaton, and instead attached to it via some wonderful invention called "the internet".
your straw man is on fire...
[ Parent ]
The diff is... (2.75 / 4) (#7)
by jeduthun on Tue Mar 09, 2004 at 04:32:23 PM EST

If all you need is simple switching, then screen is overkill. The extra stuff is why you use it instead. Also, only at the Linux console do you have Alt-Fn--what if you're an xterm? or a MacOS X terminal? etc, etc.

[ Parent ]
if I'm in xterm.... (none / 1) (#10)
by Blarney on Tue Mar 09, 2004 at 04:36:59 PM EST

If I'm in a gui desktop, then I can always crash into a text terminal with CNTRL-ALT-Fn and return with the appropriate ALT combo - usually ALT-Fn. But usually I'd just have multiple terminal windows and ALT-TAB between them.

[ Parent ]
Or even tabbed terminals. (none / 2) (#13)
by kitten on Tue Mar 09, 2004 at 05:00:38 PM EST

Konsole is a nice xterm with tabs, for people who are running all kinds of stuff in console.

I guess the only real application of screen is the ability to detach and reattach. You could screen irssi on a remote machine, for example. Then your IRC session would be the same without all the disconnecting and reconnecting - just log back into your screen when you get to work and pick up where you left off. Also useful so that you don't miss messages and such while you're commuting.

But beyond fairly narrow applications like that, I can't see much use for screen that tabbed xterms wouldn't already provide.
mirrorshades radio - darkwave, synthpop, industrial, futurepop.
[ Parent ]
splitting windows (none / 2) (#27)
by martingale on Tue Mar 09, 2004 at 08:45:18 PM EST

You can also split windows kind of like emacs. That's sometimes more useful than tabbed xterms. Of course, with a big desktop you can just open a couple more xterms and move them around.

[ Parent ]
Great on console (none / 1) (#20)
by nooper on Tue Mar 09, 2004 at 06:50:18 PM EST

The Alt-Fn method is what I have always used and find most simple. Unfortunately it only works when you're sitting at the console. So Screen is useful when you're ssh'ing/telneting in remotely, and need multiple windows running, without the inconvenience of running multiple telnet sessions.

[ Parent ]
disconnecting and reconnecting (3.00 / 4) (#23)
by BillyBlaze on Tue Mar 09, 2004 at 07:12:03 PM EST

The unique use is when you want something running perpetually, but you want to check its status from different computers. So you could, for example, ssh to your home computer from work, start doing something, then come home, and on your home computer, reconnect to that screen session. You'll be right where you left off. Also, you can have two terminals connected to one session, so you could remotely walk someone through doing something on the command line. I know no other way to do these things short of running an X or VNC server.

I personally run SETI@home in a screen session, so that when I log out or restart X, it's still running. Yes, I could do this in a text-mode virtual console, but it's less convenient to switch to text-mode to check up on it.

[ Parent ]

Attaching sessions (3.00 / 3) (#105)
by Graymalkin on Thu Mar 11, 2004 at 03:54:11 AM EST

Screen works really well for all of those apps that can't really be run using nohup but you need/want to run them without being logged in. If you're working in say emacs over SSH and some joker accidently on purpose kicks out your power cable your emacs session will stay running in screen. You can log back in and type screen -r and reattach to your screen session right where you were before you had to take someone onto the loading dock and throw them into a brick wall.

[ Parent ]
one difference (none / 1) (#124)
by ekj on Thu Mar 11, 2004 at 11:52:34 AM EST

.. is that you don't have to log in over and over again if you want to use another window. it's simply more convenient.

For example, if you are in screen, and using a shell, and you get this idea: "Give me a vi-window, but keep this one", all you need to do is say "screen vi sourcecode.c", because when you use the "screen" command inside of screen, it doesn't start a new nested one, but instead gives you a new window.

Or you can do "C-a c" (Create), and then, in the new shell that starts, type "vi sourcecode.c". I'm old enough that my prof used to yell at people doing this on the student-server, because, according to him "it wastes the memory for an unnneded instance of bash". :-)

[ Parent ]

If you use ssh, screen is worth learning. (2.95 / 21) (#14)
by waxmop on Tue Mar 09, 2004 at 05:05:55 PM EST

Sure, at home, I use (and love) gnome-terminal because of its tabs and anti-aliased fonts. But at work and at school, I'm restricted to a ghetto ssh terminal connected to my home machine. And that's where screen really shines.

Screen is great for goofing off at work - in the first window, you've got inscrutable C code, and in the next, you're firing off resumes like mad.
We are a monoculture of horsecock. Liar

Run like hell... (2.12 / 24) (#18)
by elenchos on Tue Mar 09, 2004 at 06:35:28 PM EST

...whenever you see "GNU" anywhere in close proximity to the phrase "Swiss Army Knife". Trust me, no one has the time this thing is going to cost you.


GNU stuff tends to be user hostile, but +1 still (none / 2) (#38)
by codeboy on Wed Mar 10, 2004 at 04:16:27 AM EST

I agree with you.  And their documentation is just as user hostile as their interfaces are.

However, screen is very useful.  And its about time someone wrote an article like this because the docs that come with screen try to tell you everything except how to actually get the damn program to be useful.

Just remember 3 commands:

C-a C to create a new console.
C-a N and C-a P to switch between them.  

Trying to figure out these essential commands using screen's stupid help screen and the docs is close to hopeless.

[ Parent ]

You don't even need that, really (none / 1) (#54)
by ZorbaTHut on Wed Mar 10, 2004 at 01:23:33 PM EST

I picked up screen for attach and detach specifically, and I've spend all my time with screen -r and C-a d.

First time I've heard about the rest of those features. ;)

[ Parent ]

I notice your link goes to emacs (none / 3) (#47)
by Fon2d2 on Wed Mar 10, 2004 at 11:28:43 AM EST

I find that very, very appropriate to your comment.

[ Parent ]
lol! (none / 0) (#110)
by dimaq on Thu Mar 11, 2004 at 05:59:37 AM EST

and you are right too *g*

[ Parent ]
long-term screen use (3.00 / 9) (#21)
by Baldrson Neutralizer on Tue Mar 09, 2004 at 06:54:15 PM EST

I have used screen for about 10 years, and there was a period where the constant ctrl-a contortions my left hand had to make caused some serious pain in my wrist. I finally clued in a remapped my control key back to the caps lock position (on a standard pc keyboard anyways) like a sun keyboard and the problem diminished greatly.

Also, I logged in to a linux machine a while back (I think it might have been red hat, not sure) and I noticed that the screen status bar was appearing in the title bar of my putty session. It was pretty cool. I never spent the time figuring out how to configure that setting on my own machines, but if anybody else knows how, it was a handy feature at the time.

Modern life, in EVERY ASPECT, is a cult of mediocrity.-trhurler

learn to touch type (3.00 / 7) (#26)
by martingale on Tue Mar 09, 2004 at 08:37:14 PM EST

You're not supposed to press Ctrl and A with the same hand. Press A with the left hand, and Ctrl with the right hand (assuming you have at least two ctrl keys - if not, create a few. I have 3). This comment also applies to Emacs key combos, btw. Never press two keys at the same time with the same hand, always use two hands.

[ Parent ]
Uh yeah (2.40 / 5) (#40)
by wji on Wed Mar 10, 2004 at 06:16:35 AM EST

I think I'll just play Counter-Strike with seven hands, running left-forwards while crouching, firing, signalling "go go go" and switching to USP.

Stupidity aside, do you seriously use two hands to type ctrl-combinations?

How do you type ctrl-alt-delete?

In conclusion, the Powerpuff Girls are a reactionary, pseudo-feminist enterprise.
[ Parent ]

My keyboard (none / 2) (#53)
by fn0rd on Wed Mar 10, 2004 at 12:50:24 PM EST

has 2 Ctrl keys, one on either side.

This fatwa brought to you by the Agnostic Jihad
[ Parent ]

My keyboard has four Windows keys (3.00 / 10) (#63)
by sllort on Wed Mar 10, 2004 at 04:16:28 PM EST

One in each corner, but I only pray to the one facing west.
Warning: On Lawn is a documented liar.
[ Parent ]
Just as I suspected. (1.80 / 5) (#65)
by fn0rd on Wed Mar 10, 2004 at 04:52:54 PM EST

As every right thinking Christian can deduce from centuries of map-making convention, North is always analogous to 'up'. This obviously makes West translate into 'left'. Left has long been known as the sinister side, left handed people have been shown to be sneaky, unreliable, and more likely to succumb to an early death due to their bizarre proclivities for that which is not right, and the left-hand-path is synonymous with black magic and dealings with the underworld. Therefore, you are witch.

Burn sllort!

This fatwa brought to you by the Agnostic Jihad
[ Parent ]

0 (Hide) , hitchhiking on a one-liner /nt (3.00 / 3) (#81)
by Battle Troll on Wed Mar 10, 2004 at 08:30:26 PM EST

Skarphedinn was carrying the axe with which he had killed Thrainn Sigfusson and which he called 'Battle Troll.'
Njal's Saga, ca 1280 AD
[ Parent ]
ctrl-alt-delete (none / 1) (#85)
by martingale on Wed Mar 10, 2004 at 08:55:08 PM EST

I never use that. Usually, I telnet into the box from somewhere, su to root and type "reboot".

Practicalities aside, there's usually no need to reboot while you're in the middle of typing ;-)

[ Parent ]

Are you serious???? (none / 0) (#187)
by mumble on Sun Mar 21, 2004 at 02:41:49 AM EST

OK, class, can we spot the mistakes here??

"I telnet into the box from somewhere, su to root and type "reboot""

Here are the mistakes:
telnet: sniff your login...
from somewhere: (un)trusted machine...
su: sniff another login...
root: Wahoo... Free root password!

stats for a better tomorrow
bitcoin: 1GsfkeggHSqbcVGS3GSJnwaCu6FYwF73fR
"They must know I'm here. The half and half jug is missing" - MDC.
"I've grown weary of googling the solutions to my many problems" - MDC.
[ Parent ]

what? two hands? (none / 0) (#167)
by Chani on Sat Mar 13, 2004 at 12:27:05 AM EST

I only type with one hand :)
bad habit, I know, I know... but my right hand is pretty much glued to the mouse now- I blame games that require both the mouse and keyboard simultaneously.

the funny thing is, I can type pretty quickly like this...

(and before anyone makes jokes about other reasons for typing one-handed - I'm a girl :P )
----- This insane ranting brought to you by eevil bananas. Blaa!
[ Parent ]

About that status bar (none / 1) (#141)
by IndianaTroll on Thu Mar 11, 2004 at 05:20:15 PM EST

Check fn0rd's comment above...the hardstatus lines are the ones that give the status bar on the bottom all the time.

Your personal experiences don't mean diddly in a nation of 300 million people. jubal3
[ Parent ]

use ctrl-\ instead of ctrl-a, and remap caps lock (none / 2) (#172)
by Shikari on Sun Mar 14, 2004 at 12:57:09 PM EST

I've been a screen user for about 14 years (cs. 1990) and when I started using emacs regularly, I switched my control key from ctrl-a to ctrl-\. I think this works better for the wrists as well as allows be to use ctrl-a normally on the command-line and in emacs. Plus I swap caps lock and right control so that I can use a PC keyboard like a Sun keyboard. Much better for the wrists also.

[ Parent ]
0, abstain (1.00 / 17) (#25)
by Hide The Hamster on Tue Mar 09, 2004 at 08:27:56 PM EST

+1FP,Technology, -1, GNU's Not Unix

Free spirits are a liability.

August 8, 2004: "it certainly is" and I had engaged in a homosexual tryst.

Another use (2.55 / 9) (#35)
by dn on Wed Mar 10, 2004 at 01:53:05 AM EST

Screen is also nice when, for whatever reason, your terminal keeps getting blown away. You don't have to keep putting all the editors, mail readers, and such back in order from scratch.

    I ♥

Great for the Sidekick's SSH client (none / 1) (#103)
by skallas on Thu Mar 11, 2004 at 03:29:33 AM EST

For unstable connections screen is a lifesaver. When I lose GPRS on my Sidekick, screen "saves" my session. I'm sure this applies to the ssh client for the Treos too.

[ Parent ]
-1: Please re-submit (1.03 / 33) (#36)
by I Hate Jesus on Wed Mar 10, 2004 at 01:56:00 AM EST

GNU/Please GNU/re-submit GNU/this GNU/in GNU/proper GNU/GNU GNU/speak GNU/approved by GNU/Richard GNU/Stallman.

Do you hate Jesus too?
Saying GNU Screen is as appropriate as saying... (2.75 / 12) (#37)
by jeduthun on Wed Mar 10, 2004 at 02:10:44 AM EST

... Microsoft Windows.  It's a program named "screen" by a group named GNU.  What's wrong with calling it GNU Screen?  You'll notice I dropped the "GNU" from it at most points in the article because it would have been awkward to keep repeating it, but because "screen" is such a common word, the word "GNU" is useful to distinguish the software utility from other things called "screen".  

I never say GNU/Linux unless I am referring to Debian GNU/Linux, a distribution that calls itself by that name.  Red Hat Linux and the rest are simply Linux.

[ Parent ]

Not everything is a criticism (none / 0) (#127)
by p3d0 on Thu Mar 11, 2004 at 12:34:12 PM EST

He's just kidding. Settle down.
Patrick Doyle
My comments do not reflect the opinions of my employer.
[ Parent ]
Proper Credit! (3.00 / 5) (#44)
by MalcolmCleaton on Wed Mar 10, 2004 at 09:46:08 AM EST

Please give proper credit. The appropriate term is "GNU/by".


[ Parent ]

Feh, screen. (2.81 / 11) (#52)
by zipper on Wed Mar 10, 2004 at 12:41:15 PM EST

Considering how few people use all the features of screen (and that it's huge) they ought to try dtach.

This account has been neutered by rusty and can no longer rate or post comments. Way to go fearless leader!
Thanks (2.50 / 4) (#77)
by sydb on Wed Mar 10, 2004 at 08:14:21 PM EST

This is the ONLY reason I ever wanted to use screen, and it just didn't present the incentive to learn the keystrokes in the way the vi/vim presents incentives to learn keystrokes. dtach is exactly what I want. Thanks.

Making Linux GPL'd was definitely the best thing I ever did - Linus Torvalds
[ Parent ]

Screen + gnome-terminal + freebsd = T3H SUCX (2.20 / 5) (#56)
by IndianaTroll on Wed Mar 10, 2004 at 01:51:06 PM EST

  1.  Open gnome-terminal
  2.  Ssh to freebsd server
  3.  start screen

4 cannot be fixed.  Tried stty, tset, and others.  When I try the same thing except with xterm in step 1, everything works fine.

What is wrong with my gnome-terminal?

Why can I not use wonderful screen with wonderful BSD with wonderful gnome-terminal together?  Why must gnome-terminal look so pretty and suck so much backspace?

Your personal experiences don't mean diddly in a nation of 300 million people. jubal3

re: gnome-terminal (3.00 / 5) (#62)
by JahToasted on Wed Mar 10, 2004 at 04:06:13 PM EST

did you try Edit->Current Profile then select the Compatibility tab? There's something there for the backspace key.
"I wanna have my kicks before the whole shithouse goes up in flames" -- Jim Morrison
[ Parent ]
You, sir... (none / 2) (#66)
by IndianaTroll on Wed Mar 10, 2004 at 05:44:24 PM EST

...are very good to put up with a moron like me.

Thank you for your suggestion, it worked out perfectly.

By the way, it seems that gnome terminal can be set to generate three different things for the backspace/delete keys.

The "CTRL-H" method would work if I were to set my escape character to "^H".  For instance

[me]$ stty erase '^H'

The "Delete Sequence" method would work if I were to set my escape character to "^?".  For instance

[me]$ stty erase '^?'

Is there a corresponding "ASCII escape sequence" answer for those who perhaps didn't have the option to remap their escape sequences?

Thank you once again.

Your personal experiences don't mean diddly in a nation of 300 million people. jubal3
[ Parent ]

heh (none / 0) (#153)
by JahToasted on Thu Mar 11, 2004 at 10:28:19 PM EST

That's something I usually do... post a long rant about the lack of a feature only to find out that the feature was there all along. Usually I find it myself immediately after posting too...
"I wanna have my kicks before the whole shithouse goes up in flames" -- Jim Morrison
[ Parent ]
iBook? (none / 1) (#79)
by interiot on Wed Mar 10, 2004 at 08:17:31 PM EST

How about with iBook's terminal? ssh to a linux server, start screen, delete now produces garbage, ^H doesn't work, and stty doesn't seem to help anything.

[ Parent ]
terminal.app -> rxvt. (none / 1) (#107)
by benley on Thu Mar 11, 2004 at 05:06:09 AM EST

Try setting terminal.app to export TERM as rxvt instead of xterm-color. Works like a charm. It's just in preferences.

[ Parent ]
gnome-terminal + screen scrolling? (2.40 / 5) (#64)
by JahToasted on Wed Mar 10, 2004 at 04:22:01 PM EST

I would use screen all the time if it weren't for the fact that scrolling doesn't work at all with gnome-terminal.

Also the "New Screen" flashing up when you run screen -R is quite annoying. running with -q doesn't get rid of that message either.

It would be nice if I could have gnome-terminal open a new screen terminal if one doesn't exist or reattach to an already running one automatically when I click the icon. Then I could click on gnome-terminal, start a kernel compile, close gnome terminal, and open the terminal later to check on the status of the compile. But I guess the idea of using a GUI alongside the CLI never occured to the smelly GNU/Hippies.

Anyway its alright for ssh sessions I guess, but it could be much more useful.
"I wanna have my kicks before the whole shithouse goes up in flames" -- Jim Morrison

You can (none / 0) (#76)
by sherbang on Wed Mar 10, 2004 at 08:10:51 PM EST

just make a laucher for gnome terminal something like this:
gnome-terminal -e "screen -d -RR"

You still have that annoying "new screen" popup thing, but I doubt that's a big deal.

[ Parent ]

yeah, I know that (none / 0) (#150)
by JahToasted on Thu Mar 11, 2004 at 10:19:01 PM EST

That what I tried. Problem is, it doesn't scroll at all.
"I wanna have my kicks before the whole shithouse goes up in flames" -- Jim Morrison
[ Parent ]
see the FAQ (none / 2) (#119)
by Laz on Thu Mar 11, 2004 at 10:56:43 AM EST

FAQ -> Q: My xterm scrollbar does not work with screen.

[ Parent ]
That FAQ also has this tidbit: (none / 0) (#130)
by glor on Thu Mar 11, 2004 at 02:29:06 PM EST

Q:    When you start screen a page of text comes up to start you off. Is there a way to get rid of this text?

A:    Just put the following line in your ~/.screenrc file:

startup_message off

which presumably gets rid of the 'New Screen' message.

Disclaimer: I am not the most intelligent kuron.
[ Parent ]

nope (none / 0) (#151)
by JahToasted on Thu Mar 11, 2004 at 10:20:30 PM EST

that does the same as the -q option. It gets rid of the help screen, but not the "New Screen" thing at the bottom.
"I wanna have my kicks before the whole shithouse goes up in flames" -- Jim Morrison
[ Parent ]
Is that the _title_ of the new screen? (none / 0) (#181)
by Anonymous Hiro on Wed Mar 17, 2004 at 09:36:23 AM EST

Is that the title of the new screen you're referring to?

[ Parent ]
I saw that just after I posted (none / 0) (#152)
by JahToasted on Thu Mar 11, 2004 at 10:22:55 PM EST

but it's only relevant to xterm, it doesn't apply to gnome-terminal.
"I wanna have my kicks before the whole shithouse goes up in flames" -- Jim Morrison
[ Parent ]
No point. (1.85 / 7) (#71)
by Phillip Asheo on Wed Mar 10, 2004 at 07:30:16 PM EST

Why not just run a couple of hundred Xterms and 9wm.

"Never say what you can grunt. Never grunt what you can wink. Never wink what you can nod, never nod what you can shrug, and don't shrug when it ain't necessary"
-Earl Long

A real life practical example (3.00 / 9) (#73)
by esrever on Wed Mar 10, 2004 at 07:48:45 PM EST

I need to run an interactive, 36 hour process on a server.  The server is headless, so I can only interact with it over a terminal session.  I need to be able to take my laptop home with me at night for remote support purposes, so how do I satisfy both the need to detach my laptop, and the need to be able to keep the interactive session running?  The answer, of course, is 'screen'.  It works beautifully.

Audit NTFS permissions on Windows
[ Parent ]
Slow sucky connections (3.00 / 5) (#82)
by interiot on Wed Mar 10, 2004 at 08:30:29 PM EST

I need to be able to access my apps remotely, over a cable modem that's sometimes slowly/hiccupy, and occasionaly over a modem or cellular data connection. I don't want to restart all my apps every time I drive under a bridge, and really can't use more than 8 bits to display a character on the screen.

[ Parent ]
BECAUSE X IS SHIT. (3.00 / 3) (#87)
by it certainly is on Wed Mar 10, 2004 at 09:03:28 PM EST

If your network connection goes, so do all your applications. Forever. Great fucking idea, yeah?

Here's a novel idea: why not keep windowing system state on the same fucking server as the application? Then you could even move sessions from machine to machine.

kur0shin.org -- it certainly is

Godwin's law [...] is impossible to violate except with an infinitely long thread that doesn't mention nazis.
[ Parent ]

not a novel idea actually -- xmove (2.66 / 3) (#94)
by Undesirable Username on Wed Mar 10, 2004 at 10:49:14 PM EST

xmove is a pseudoserver that is much like screen for X. it works, but it's not being actively developed. if someone was looking for a pet project, this is a great one to adopt -- the author had no problem with it last I asked. Here's one of the places it lives:

[ Parent ]
Hmm (2.25 / 4) (#129)
by awgsilyari on Thu Mar 11, 2004 at 01:48:07 PM EST

If your productivity depends on keeping applications open 24/7, I'd say there's something wrong with your work process.

At my old office we'd commonly have power outages due to shit building wiring in another part of the complex. Once a month or so the whole office would go "poof."

I never, ever lost more than about 10 seconds worth of work when that happened. And it takes no time at all to revive the environment using scripts. But if you'd rather force yourself to work in a single terminal all the time just to avoid the one time effort of writing a script that launches your work environment, I guess that's your prerogative.

Please direct SPAM to john@neuralnw.com
[ Parent ]

Great idea, Sherlock. (1.66 / 6) (#131)
by tkatchev on Thu Mar 11, 2004 at 02:32:20 PM EST

Keep telling the user that he's an idiot instead of fixing your insanely stupid design decisions.

What a way to win friends and influence people, huh.

   -- Signed, Lev Andropoff, cosmonaut.
[ Parent ]

No time at all. Yeah, right. (3.00 / 4) (#166)
by it certainly is on Fri Mar 12, 2004 at 10:53:06 PM EST

I work on SunRays. Normally, I leave everything on 24/7.

When I get into work, I insert my card into the SunRay, type my password and hey-presto, all my apps are there where I left them. 10 seconds. Thanks to the non-X remote desktop protocol that exports a virtual X server running on the same machine as all the applications.

If my X session were to crash, I would have to:

  • Log in. Username/password, wait 3 minutes for the full GNOME environment to launch on a server with 400 concurrent users.
  • Launch Evolution, the mail client. It takes roughly 40 seconds to appear, much longer if it's my first login of the day and it has lots of new mail to filter.
  • I can concurrently launch Firebird. 20 seconds. Then I have to launch the web apps I need. I have a super-bookmark that does this, I click it and get all 3 apps in 3 tabs. Each one needs a login/password, but I've stored those, so I only need to click the login buttons. And, of course, move the suddenly appearing main Evolution window out of the way, as it interrupts me.
  • I can concurrently launch my three database apps. EMEA, Americas and APAC. I also need to make sure I don't confuse each database, so I need to stagger launch times. Alternatively, I could let them all launch on the same screen and spend 3 minutes working out which one is which. Each database has the same GUI. They all need login/passwords. I'm not allowed to store these, I have to type them in. After spending 10 seconds on each username/password, it's roughly 1 minute before the main selection window appears. I can then click on the Case-tool, Task-tool and Contract-tool buttons. These take roughly 30 seconds (EMEA, where I am) to 4 minutes (APAC, half-way around the world from me) to appear.
So yeah, there's something wrong with my work process. I actually have to do work.

kur0shin.org -- it certainly is

Godwin's law [...] is impossible to violate except with an infinitely long thread that doesn't mention nazis.
[ Parent ]

Your applications do not always 'go' when X dies. (none / 1) (#159)
by Phillip Asheo on Fri Mar 12, 2004 at 02:16:49 PM EST

Only if they are written that way. Its perfectly possible to write X apps that can survive an X11 server crash. Its just that most people don't bother.

"Never say what you can grunt. Never grunt what you can wink. Never wink what you can nod, never nod what you can shrug, and don't shrug when it ain't necessary"
-Earl Long
[ Parent ]

There's a reason they don't bother. (3.00 / 5) (#165)
by it certainly is on Fri Mar 12, 2004 at 10:35:22 PM EST

Assuming you ignore the "terminate process" signal that xlib will send you on link failure, you also lose all state that you stored in the X system, i.e. window/widget lists and their states. You have to open everything again, in the right order.

You also have to maintain some kind of signalling system whereby the user can say "I've made a brand new X Display, please reopen the entire application here". There is no standard for this.

While it might be possible for a few applications like emacs to do this (after all, it already supports the same emacs-server concurrently doing the editing work requested both X and tty clients, with the buffers residing in the server rather than the clients), for the majority of graphical applications it is completely unacceptable to be expected to doubly maintain all windowing state in case the entire GUI subsystem crashes.

Windows and MacOS don't have this problem, because their "remote desktop" protocols leave state on the server and simply forward new graphics data to a dumb client. The same is true of Sun's SunRay mobile desktops. The SunRay is a dumb terminal. X clients talk to X servers on the same E12k. Those X servers graphics are then forwarded to the individual Rays using a remote desktop protocol, not the easily flakey X protocol.

There are robust, fault-tolerant protocols for remote graphical interfaces. X is not one of them.

kur0shin.org -- it certainly is

Godwin's law [...] is impossible to violate except with an infinitely long thread that doesn't mention nazis.
[ Parent ]

Why not? (2.75 / 4) (#92)
by John Thompson on Wed Mar 10, 2004 at 10:05:45 PM EST

Phillip Asheo wrote:

Why not just run a couple of hundred Xterms and 9wm.

A couple reasons: screen is stateless, meaning you can disconnect from your screen session without disturbing the processes running with screen. In contrast, if you disconnect from an X session, the processes running in that session will die.

Second, if you're connecting through a non-graphical terminal (serial terminal or text console, for example) you can't run X. One of my machines is an old 5x86/133 with 32M running NetBSD. It acts as a DHCP server and samba authentication server for my home network and not much else and it's stable as a rock. The only time I've had to shut it down in the last few months was when I had to replace the UPS. It's possible to run X on that machine, but I'd rather save the limited resources for other things, so I use ssh and screen to access and administer the machine.

X would be pointless in such a case.

[ Parent ]
screen on the Hurd (none / 1) (#108)
by cpghost on Thu Mar 11, 2004 at 05:14:22 AM EST

You may not always have X available. Sometimes, you may not even have virtual text consoles. In GNU/Hurd, screen is the only way to have multiple sessions, lest you can get XFree86 to start...

cpghost at Cordula's Web
[ Parent ]
Re: screen on the Hurd (none / 0) (#176)
by mbanck on Mon Mar 15, 2004 at 01:48:50 PM EST

In GNU/Hurd, screen is the only way to have multiple sessions, lest you can get XFree86 to start...

That's not true anymore. About one and a half years ago, Marcus Brinkmann has committed his Hurd console into CVS, it's just not enabled by default as it did not play nicely with X. However, this issue has been solved recently, the patch still needs testing and review though.

The Hurd console is quite cool (see the first URL above for a description) and supports screen-style detaching natively.


[ Parent ]

This really doesn't sound that useful. (none / 2) (#74)
by lukme on Wed Mar 10, 2004 at 08:02:11 PM EST

personally, I perfer to have multiple terminal sessions opened. I position them in such a way that I know in this window I do a specific action based on its position. This follows how I normally do things, ie I sit down at my computer and do certain work there. I go to the kitchen and prepare a snack (I probably wouldn't want to cook anywhere near my computer). I go to the grocery store to buy food, which I certainly wouldn't do either in my kitchen or at my computer (I believe that the e-grocers have gone under, besides I live so far out, they wouldn't want to deliver to me anyway). Since I believe that this is a general metaphor as to how people work, opening just window with multiple terminal sessions would be confusing.

It's awfully hard to fly with eagles when you're a turkey.
Screen makes it less confusing (none / 1) (#78)
by interiot on Wed Mar 10, 2004 at 08:15:14 PM EST

1) you waste screen space by doing that

2) that only works with so many windows, after a while you have to start overlapping them. At which point Screen is much less confusing because you just remember things like "screen #1 is my main email box, screen #9 is the mbox for mailing list X, screen #8 is ircii, screen #7 is the build that's taking forever, screen #2 is for the main source file editing, etc....". Changing between numbered terminals is much faster than trying to find the right window to alt-tab to (once you go beyond 3 main windows you're working with).

[ Parent ]

It comes down to how you work. (2.50 / 2) (#83)
by lukme on Wed Mar 10, 2004 at 08:47:34 PM EST

If it work for you, by all means do it.

Personally, I would get confused between 12 and 21. Having 21 windows opened on my destop is not unusal. I have also seen how my co-workers work, and some of the take it a bit further by having different colors for each task they are performing.

It's awfully hard to fly with eagles when you're a turkey.
[ Parent ]
Ahh (none / 1) (#128)
by awgsilyari on Thu Mar 11, 2004 at 01:41:38 PM EST

Changing between numbered terminals is much faster than trying to find the right window to alt-tab to

Those of us with multiple large display devices (yay, xinerama) don't use alt-tab because it's faster to just bump the mouse over to the correct window. I've got 17 windows open right now that I can count, all of which are sized to fully usable sizes, and none of them overlap. Then again, this is on two 19 inch screens of real estate.

I also use virtual desktops for collections of related tasks. In total I've got over 60 windows open right now in four virtual desktops.

I've tried using screen and it's a massive headache. It was extremely useful back when I did all my UNIX work over a terminal session, and back when my PC was too crappy to run X. Now, when it's easy to have multiple large screens, I don't see the point...

Please direct SPAM to john@neuralnw.com
[ Parent ]

screen -x (3.00 / 2) (#100)
by Phil Gregory on Thu Mar 11, 2004 at 01:00:09 AM EST

Not sure if this would be of interest to you, but you can attach multiple times to the same screen session. Just use screen -x instead of screen -r. I work with several xterms visible, but all running screen -x to the same session. That gives me all the benefits of screen combined with the ability to see more things at once.

screen displays can themselves be split to show more than one window at once, but they can only be split horizontally and the splits aren't persistent without some hackery. I just run my xterms tiled inside of ion.

355/113 -- Not the famous irrational number PI, but an incredible simulation!
[ Parent ]
The difference (none / 1) (#180)
by Anonymous Hiro on Wed Mar 17, 2004 at 09:28:54 AM EST

With screen you can disconnect a session, logout and resume it later from another computer/location (it still runs in the background).

You can't do that with your "tons of xterms" method - you have to return to the same console to see your xterms.

But you can do that with VNC (and open tons of xterms).

The low bandwidth, connection and resource requirements of screen still make it very useful and more appropriate than VNC or other stuff.

Of course, if there are bugs, screen can be a security prob.

[ Parent ]

Making it go away (none / 3) (#80)
by donio on Wed Mar 10, 2004 at 08:19:22 PM EST

C-a C-\ or if that doesn't work (because your terminal can't send
that sequence or something), C-a C-: quit [RET]

silly question (none / 3) (#84)
by clover_kicker on Wed Mar 10, 2004 at 08:48:47 PM EST

I'd like to configure screen(1)'s startup behaviour to automagically split the screen, running thisapp in one window and thatapp in the other, with the focus on thisapp.

Anyone know how I'd do this?
I am the very model of a K5 personality.
I intersperse obscenity with tedious banality.

re: silly question (2.80 / 5) (#88)
by interiot on Wed Mar 10, 2004 at 09:03:45 PM EST

See the example of the screen command that you put in your ~/.screenrc.

[ Parent ]
thank you sir! (none / 3) (#96)
by clover_kicker on Wed Mar 10, 2004 at 11:35:06 PM EST

$ cat .screenrc
screen -t top -L top
screen -t netstat -L netstat -w 5

I am the very model of a K5 personality.
I intersperse obscenity with tedious banality.

[ Parent ]
What about jumping to the beginning of a command? (3.00 / 6) (#90)
by frankwork on Wed Mar 10, 2004 at 09:26:51 PM EST

In bash, and I'm assuming several other shells, C-a takes you to the beginning of the command line (C-e takes you to the end, most of these are just like emacs).

I just tried screen, and it doesn't preserve this behavior.

A couple of related shortcuts in bash -- C-p goes to the previous command (like up arrow, C-n is down arrow), C-r does a reverse i-search of your command history. C-_ undoes what you typed (but only the current, as yet unexecuted command line). C-f and C-b are like the right and left arrows, respectively, and M-f and M-b jump forward and backword a word at a time. M-d deletes a word (forward delete), C-d deletes a letter (likewise). C-k and C-y also work as you'd expect.

Note that many of these work in (of all places) Safari (no doubt due to its KHTML origins).

Here's how: (3.00 / 6) (#91)
by jonathan21 on Wed Mar 10, 2004 at 09:48:13 PM EST

Since C-a is the command initiation sequence by default, you have to use C-a a for a literal C-a to be passed to the session. This can be changed, however. C-a ? will give you a useful list of all the command sequences supported.

[ Parent ]
redefining the command character (3.00 / 4) (#98)
by donio on Thu Mar 11, 2004 at 12:31:46 AM EST

In addition to the previous suggestion (C-a a) you have the option to
redefine the command character. If you are a heavy user of the
emacs-ish key bindings then C-a is just too important to give to
screen. I picked C-j because I seldom use it[1] and it's easy to hit on
my (somewhat unusual) keyboard. From my .screenrc:

escape ^jj

While I am at it, here some of my other favorite .screenrc settings:

nethack on

hardstatus alwayslastline "%{rk}%H %{gk}%c %{yk}%M%d %{wk}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wk}%?%+Lw%?"

(The stuff after hardstatus is supposed to be in a single line,
hopefully it won't get mangled)

[1] I use something else for newline-and-indent in Emacs.

[ Parent ]

what about backspace (none / 0) (#142)
by coward anonymous on Thu Mar 11, 2004 at 06:01:48 PM EST

backspace stopped working instantly in screen as well...

[ Parent ]
Screen's command character (none / 1) (#147)
by static on Thu Mar 11, 2004 at 09:40:08 PM EST

You can change it when you start screen with the -e option. I use this to have nested screen's; the outer uses C-o and the inner ones use C-a.

Also, bash supports a vi-mode which removes the C-a problem. set -o vi.


[ Parent ]

Anywhere in MacOS X (none / 0) (#194)
by MochaMan on Thu Mar 24, 2005 at 04:17:39 AM EST

Turns out I'm replying over a year late, but every text field in Mac OS X supports the emacs editing keys, not due to KHTML, but due to its openstep origins.

[ Parent ]
An awesome tool (3.00 / 13) (#93)
by Shibboleth on Wed Mar 10, 2004 at 10:24:59 PM EST

'Back in the day', when we used to be on dumb vt100 terminals in any one of a dozen labs at uni, screen was the Best Program Ever.

Its ability to switch and detach was beyond useful. For instance, we could be signed in on one server, coding, with one screen in Jove, another in a mail program, and another at a command prompt. We'd then have an ftp session going on a whole different server, and a MUD client or nethack game on yet another screen (on another server).

If some Authority Figure would walk in, a control-a, control-a would be enough to hide our nethack game from view. Best of all, if someone comes in, says 'everybody out, class about to start', you can just do a control-a-d, 'exit', and pick up your bag and leave, go to another lab, and resume precisely where you left off (except for the MUD, you were dead. :))

I still find it useful for my gentoo laptop. I have a root login, start screen, then start compiling some large program. Then I just detach the session, log out, and have a secure laptop sitting there compiling. If someone comes up to it, they can't just alt-function through the terminals and get a nice, open root session on screen.

Indeed (none / 1) (#101)
by leviramsey on Thu Mar 11, 2004 at 02:37:44 AM EST

Really the only thing I use screen for now is to startx, so that the various and sundry X logging doesn't eat a terminal.

[ Parent ]
xmx: A Screen-ish program for X (2.75 / 4) (#95)
by froindlaven on Wed Mar 10, 2004 at 11:21:28 PM EST

Here's a cool X program which is both an X client and server. You can attach/detach to it much like screen. I tried it out when I had to jump around from lab machine to lab machine and it worked pretty well. In the end, I opted for just using ssh and screen.

Screen on MacOS X (2.66 / 3) (#102)
by sakusha on Thu Mar 11, 2004 at 03:25:29 AM EST

screen is installed in MacOS X, I have FINK installed but I don't think I installed any GNU utils in FINK yet, it must come with the default OSX install.

But there really is no need for screen. Just download iTerm, it has multiple terminal management within one window.


so? (none / 1) (#145)
by lowmagnet on Thu Mar 11, 2004 at 09:27:57 PM EST

so you missed the whole part about detaching and re-attaching later, or from somewhere else? iTerm doesn't do this. Also, I use screen on critical processes, because iTerm still crashes randomly in its current incarnation.

[ Parent ]
Not enough (none / 0) (#156)
by emagius on Fri Mar 12, 2004 at 07:22:21 AM EST

Being able to use multiple virtual terminals in one Xterm is the least of screen's features.

[ Parent ]
First thing I thought of (3.00 / 5) (#104)
by ragnarok on Thu Mar 11, 2004 at 03:43:08 AM EST

and what I continue to keep thinking, is, how useful for something like bochs, or Hercules, dosbox, or altair88, or other emulators/virtual machines.

If you're familiar with their operation, they tend to tie up a terminal, even if you've got multiple virtual terminals on your kde/gnome/whathaveyou X Window System window manager.

So you fire up screen, C-a c then fire up bochs running FreeBSD and it pops up the X Window displaying said OS, then C-a n and C-a c again, fire up vax simh.netbsd with ssh terminals, C-a n and C-a c again, fire up vm.sys which comes up with its own x3270 terminals, C-a n and C-a c again, fire up Basilisk II running Macintosh System 7.5, C-a n and C-a c again, and fire up the altair88 simh emulator running MP/M 2 with an ssh terminal, etc.

And because they can all be detached, that's one heap of desktop real-estate you won't worry aobut losing, while you can carry on learning and using various emulators to your heart's content.

Even better yet, you can make use of the various Xterms' multiple shell/session setups to do work on one Xterm's shell, while using screen plus emulators/virtual machines on yet another.

A geek's dream.

"And it came to healed until all the gift and pow, I, the Lord, to divide; wherefore behold, all yea, I was left alone....", Joseph Smith's evil twin sister's prophecies

Sorry... (3.00 / 3) (#146)
by emmons on Thu Mar 11, 2004 at 09:32:47 PM EST

It doesn't hold open X11 connections. Those get killed when you close your X session, and hence the programs relying on them crash. It's a bummer, but hey.. screen still rocks. It's just X that sucks. :)

In the beginning the universe was created. This has made a lot of people angry and been widely regarded as a bad move.
-Douglas Adams

[ Parent ]
Screen as poor guy's VNC (3.00 / 5) (#111)
by mikeymckay on Thu Mar 11, 2004 at 06:05:17 AM EST

My favorite feature of screen is being able to share a terminal with someone else in real time. It is a great way to collaborate on a project together, or to teach someone how to do various command line magic.

The great thing is that the command line is only text, so two users could be on a slow dialup connection but fully able to work together. It is like sharing a vnc connection, but needing just a fraction of the bandwidth.

To set this up you do something like this:

user1 runs screen
runs command "ctrl-A: multiuser on"
then "ctrl-A: acladd user2"

user 2 then runs
screen -x user1

(I think the above process may have changed slightly in recent versions due to some security issues)


Splitvt... (none / 3) (#112)
by mikelist on Thu Mar 11, 2004 at 07:20:17 AM EST

is a similar idea, but both/all screens are visible simultaneously. I use that one more, screen is like having several vts logged in at the same time.

Screen can do that, too -nt- (3.00 / 2) (#155)
by emagius on Fri Mar 12, 2004 at 07:20:46 AM EST

[ Parent ]
screen + bittorrent (3.00 / 5) (#113)
by davros4269 on Thu Mar 11, 2004 at 08:16:40 AM EST

Is a great combination.

I use btdownloadcurses and run it in a screen session. At this house, others use this machine, so if they log in, my downloads continue - when I log back in, I open a shell and: screen -r and I can see my progress.

This old crate really feels the bog when I have several downloads going, so I often use an even older crate with lots of ram and no hard drive - it runs Knoppix without X (knoppix 2). I SSH in and use screen so I can watch my downloads in their full ascii glory...

I also keep screen running on my firewall machine, an even older box, also without X running...

Screen is so much nicer than using, say, nohup or similar on a time-intensive command line job. I can't live without it.
Will you squirm when you are pecked? Quack.

How I use it (3.00 / 6) (#115)
by Piquan on Thu Mar 11, 2004 at 08:51:43 AM EST

Two tips from how I use screen.

First, if you use Emacs, or the Emacs bindings for bash, then you'll probably want to add escape ^Za to your .screenrc. This lets you use ^Z instead of ^A, so you can use Emacs more naturally. Who needs ^Z in screen anyway, and if you need it, ^Za will do the trick.

Second, I find screen great for multiuser collaboration. I'm helping a friend in his programming studies, usually over the phone. We'll often use a shared screen session, so we can watch each other work on code. The sequence is: he creates a screen session, hits (assuming ^Z is your escape char) ^Z:multiuser on[RET]^Z:acladd piquan[RET] (where my username is piquan); then I run (from a normal, non-screen terminal) screen -x jrh/ (where his username is jrh).

Better choice for command key: Backquote (none / 3) (#116)
by Xenophon Fenderson, the Carbon(d)ated on Thu Mar 11, 2004 at 09:03:09 AM EST

As a long time Emacs and Screen user, I've always prefered backquote to other control key bindings, mainly because it is infrequently used, out of the way, and doesn't require chording of some kind.

Rev. Dr. Xenophon Fenderson, the Carbon(d)ated, KSC, mhm21x16, and the Patron Saint of All Things Plastic fnord
I'm proud of my Northern Tibetian heritage!
[ Parent ]
I used to use backquote all the time (none / 1) (#137)
by grouse on Thu Mar 11, 2004 at 04:42:27 PM EST

to get the output of commands in the shell but now I use $(command) instead so that might be a good idea.

But I've already gotten used to C-o, which was the least useful key combination I could find (I never run pine under screen).

You sad bastard!

"Grouse please don't take this the wrong way... To be quite frank, you are throwing my inner Chi out of its harmonious balance with nature." -- Tex Bigballs
[ Parent ]

making it go away (none / 2) (#118)
by mikpos on Thu Mar 11, 2004 at 10:19:55 AM EST

C-a \ or C-a C-\ by default will kill screen and all its windows. However, in the default config file (this isn't nearly confusing enough), I believe these are rebound to do nothing, with a comment saying that they are "dangerous".

More .screenrc fun (3.00 / 7) (#121)
by fn0rd on Thu Mar 11, 2004 at 11:03:58 AM EST

#kill startup message
startup_message off

# define a bigger scrollback, default is 100 lines
defscrollback 1024

# on Debian backspace should send char `177':
bindkey -k kb stuff "177"

# An alternative hardstatus to display a bar at the bottom listing the
# windownames and highlighting the current windowname in blue. (This is only
# enabled if there is no hardstatus setting for your terminal)
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "

# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

# Example of automatically running some programs in windows on screen startup.
# Use the form: screen [-flag] [window name] [window number] [program to run in window]
# The -t flag means that the window in which that program is running
# closes when you exit that program, so if you quit pine
# window 2 closes.

screen bash
screen -t emacs 1 emacs
screen -t mail 2 pine
screen -t slashdot 3 lynx http://www.slashdot.org/
screen -t k5 4 lynx http://www.kuro5hin.org/
screen -t bar 5 ssh foo@bar

# I cribbed most of this from /etc/screenrc
# Check it out on your own to learn more about keybindings and whatnot.

This fatwa brought to you by the Agnostic Jihad

Modern day "detach" feature for GUIs... (3.00 / 4) (#122)
by bgarcia on Thu Mar 11, 2004 at 11:10:32 AM EST

If you like the idea of a "detach" feature, and wish it could apply to your X session or Windows machine, it is available.

VNC will allow you to view a desktop on any machine on a network. It can be very useful for working from home.

For the graphical crowd (none / 2) (#123)
by sleepingsquirrel on Thu Mar 11, 2004 at 11:22:19 AM EST

You might want to check into ratpoison. It does for xwindows what screen does for terminals...
"Ratpoison is a simple Window Manager with no fat library dependencies, no fancy graphics, no window decorations, and no rodent dependence."

No it doesn't (I think) (3.00 / 2) (#125)
by Dr. Zowie on Thu Mar 11, 2004 at 12:21:35 PM EST

Ratpoison is a full-screen, no-frills window manager. I browsed the documentation, and didn't see any virtual-screen-like features. Is there something I'm missing? A fully transportable X environment would be a pretty cool thing.

[ Parent ]
Remote X11. (3.00 / 2) (#143)
by RangerElf on Thu Mar 11, 2004 at 06:04:55 PM EST

Xvnc will do that; you configure it as you would a normal window manager, except that when it runs there's no local display, only a virtual one.

To view what's "onscreen", you need to connect to it vía a VNC client.  It's quite nifty.


[ Parent ]

can it be suspended? (none / 1) (#144)
by emmons on Thu Mar 11, 2004 at 09:26:08 PM EST

Can you suspend your connection and reattach later from a different computer? To me, this is by far the most useful feature of screen. If I run a 3 hour process on a remote server, with screen I don't have to worry about losing anything if my connection to the server goes down. It's marvelous.

When I see an X app that can do that, I'll be impressed. :)

In the beginning the universe was created. This has made a lot of people angry and been widely regarded as a bad move.
-Douglas Adams

[ Parent ]

Yes it can. (none / 0) (#149)
by cburke on Thu Mar 11, 2004 at 09:57:33 PM EST

As long as vncserver is running, your desktop is alive.  Close the client, and the server is still there.

Some people where I work use vnc exclusively, even when sitting at their workstation, so when they go home they have the exact same desktop.  Me, I never liked the "windows trapped inside a bigger window" method of running remote applications, so I only use vnc for graphical apps with lots of redraws where it provides a speed advantage over tunneling X through ssh.

Screen, however, would still be very useful for situations with less bandwidth, and of course in general for running/controlling console apps.

[ Parent ]

re: can it be suspended? (none / 0) (#170)
by froseph on Sat Mar 13, 2004 at 12:12:11 PM EST

an x proxy (like xmove) + ratpoisen should do the trick

[ Parent ]
ratpoison (1.00 / 2) (#126)
by DJ Google on Thu Mar 11, 2004 at 12:24:33 PM EST

ratpoison is horrible, confusing and you can't use half of X11 apps with it. It is everything a WM shouldn't be.

Join me on irc.slashnet.org #Kuro5hin.org - the official Kuro5hin IRC channel.
[ Parent ]

PWM is faster and smaller and does same thing. n/t (1.00 / 2) (#163)
by sudog on Fri Mar 12, 2004 at 04:50:37 PM EST

[ Parent ]
Recursive screens... (3.00 / 8) (#134)
by Merc on Thu Mar 11, 2004 at 03:37:39 PM EST

Say I have a really flaky connection to a remote server. I want to run screen on it so if I get detached then I don't lose anything, right?

But screen's such a great program that I want to use it locally too, right? So what happens now when I use screen locally and connect to a remote machine, running screen there? I suppose I could have different escape characters, but that seems nasty. Does anybody deal with this situation?

This is not a pipe (none / 2) (#135)
by Kyle on Thu Mar 11, 2004 at 03:43:07 PM EST

I generally try to avoid this situation, but the few times I've been there, I end up bouncing on the 'a' key a lot (with and without holding control as well). Rewiring the escape character one one session or the other is a better long-term solution, but it requires that I read the manual.


[ Parent ]

Yes. The solution is simple: (none / 3) (#140)
by sudog on Thu Mar 11, 2004 at 05:20:00 PM EST

If you're using Control-A as the primary screen escape sequence, you'll need to have it send that control-a to the remote screen, like so:

Control-A, A

..at which point, you can tunnel from there to another screen, and so on, until you hit the requisite number of "a"'s after the Control-A, and you can run your command (space, for example, to switch to the next screen.)

Because Control-A is used to pull the cursor back to the start of the line in bash, I've remapped the Control-A to Control-R. It's the least-used control-sequence on my keyboard that doesn't have a special job-control meaning to it, and works well for my hands because the R is further up and I don't have to contort my fingers to click it.

All in all, screen rocks--especially the detaching part. I literally use it extensively, every day both at work and at home.

[ Parent ]

you use bash and DON'T use ^R all the time? [nt] (none / 0) (#157)
by tx on Fri Mar 12, 2004 at 08:53:34 AM EST

[ Parent ]
No need. I have a history-searching alias instead. (none / 1) (#162)
by sudog on Fri Mar 12, 2004 at 04:48:04 PM EST

That way I don't have to be limited by crappy pattern-matching. All I have to do is:

h '\.something.*'

... and it retrieves likely pattern-matches, paginates them if there're more than a screenful, and all I need to do is:


Seems simpler to me when my history is 100 000 lines.

[ Parent ]

'set -o vi' eliminates need for ^R [n\t] (none / 1) (#184)
by tbc on Thu Mar 18, 2004 at 02:31:52 PM EST

[ Parent ]
Um, I use control-R all the time (reverse i-search (none / 0) (#160)
by Merc on Fri Mar 12, 2004 at 03:38:25 PM EST

But I've mapped Ctrl-Q to the key in screen. I don't use Ctrl-Q in the shell much since it's often a flow control key, but since I never use flow control, it's freed up. As an added benefit, Ctrl-Q Ctrl-Q toggles the previous screen.

[ Parent ]
I don't use c-r in bash, and: (none / 0) (#161)
by sudog on Fri Mar 12, 2004 at 04:43:59 PM EST

If you're logged in through any other provider, or shell session, your control-q will be intercepted and interpreted before ever reaching your screen session.

[ Parent ]
And this brings up something else ... (2.57 / 7) (#136)
by pyramid termite on Thu Mar 11, 2004 at 04:25:10 PM EST

... I used to dual-boot between linux and windows for several years. I knew about console mode switching, I knew about xterms and I'd read several books and many, many documents.

This is a useful program. And yet, with my moderate experience and reading, I'd never heard of it. Even though I probably had it.

Conclusion? The linux world really needs to get its act together on documenting and explaining stuff if it wants to persuade the Micro$erf world to switch.

On the Internet, anyone can accuse you of being a dog.
How I discovered 'screen'. (3.00 / 2) (#168)
by it certainly is on Sat Mar 13, 2004 at 12:34:44 AM EST

I had access to a public UNIX server. From a few 'w' commands it was clear that everybody was using screen, bash and ircii, occasionally bitchx and eggdrop. Only I used tin (to download porn, of course).

kur0shin.org -- it certainly is

Godwin's law [...] is impossible to violate except with an infinitely long thread that doesn't mention nazis.
[ Parent ]

I agree ;-) (3.00 / 4) (#138)
by dumky on Thu Mar 11, 2004 at 05:03:35 PM EST

I posted a similar story a month ago: Essential utility: "screen".
Screen is really an amazing program.
You can quit with 'C-a C-\' (from screen doc).

Yet more screen tricks. (3.00 / 7) (#148)
by static on Thu Mar 11, 2004 at 09:53:29 PM EST

First of all, a lot of readers don't realize that using screen to multiplex an xterm is actually a subtly different solution than starting a dozen xterms. The difference is that in screen you can select the screen you want directly. Doing that with all your xterms requires assistance from your window manager. Or a term program (like Konsole) that has tabbing et al.

Second: if you find yourself opening more and more screens, you might like the following commands in your .screen.rc.:

bind  ) select 10
bind  ! select 11
bind  @ select 12
bind \# select 13
bind \$ select 14
bind  % select 15
bind \^ select 16
bind  & select 17
bind  * select 18
bind  ) select 19

The default commands include Ctrl+a 5 to select screen 5; this makes Ctrl+a Shift+5 select screen 15. :-)

Last; although mention was made of the scrollback (Ctrl+A Esc), you can use this to copy-n-paste between screens. Look in the screens manpage* for details but if you use vim you might like this instead of the default:

# Prepend/append register [/] to the paste if ^a^] is pressed.
# This lets me have autoindent modes in vi(m).
register [ "\033:se paste\015a"
register ] "\033:se nopaste\015a"
bind ^] paste [.]

The defaults toggle autoindent mode but that's not always sufficient. And vim's paste mode is actually designed for this.


* unlike so much other GNU software, the man page is really quite good and doesn't point you to an info page.

Or use a patch... (none / 0) (#178)
by azul on Mon Mar 15, 2004 at 09:38:38 PM EST

Or, with regards to your second tip concerning using Screen with a lot of terminals, use my patch that allows you to organize your terminales in a n-ary tree (as opposed to an array). It's a shame it generated soo little interest from the developers, I would really like to get it incorporated into the official version.

[ Parent ]
Wish for somthing else (1.40 / 5) (#158)
by n8f8 on Fri Mar 12, 2004 at 09:45:29 AM EST

Like a damn widget for changing the screen resolution on a notebook. And even better, make it so a user can right click on the desktop to access it.

Sig: (This will get posted after your comments)
reminds me of windows xp (1.00 / 8) (#169)
by auraslip on Sat Mar 13, 2004 at 02:08:24 AM EST

How to map Ctrl-Tab? (none / 1) (#171)
by BranchingLichen on Sun Mar 14, 2004 at 12:06:16 AM EST

Rather than using Ctrl-A N and Ctrl-A P, I'd like to use Ctrl-Tab and Ctrl-Shift-Tab to switch to the next / previous screen.

Does anybody know how to do this?

Ctrl-Tab would be nicely consistent with many other applications, e.g. switching the active tab in Mozilla. A general standard in Microsoft Windows and many other environments is: Alt-Tab changes the application, Ctrl-Tab changes within an application.

keyboard magic (3.00 / 2) (#175)
by benley on Sun Mar 14, 2004 at 10:06:10 PM EST

Well, I don't know about ctrl-tab, but here's what I have in my screenrc to enable ctrl-left and ctrl-right selection of previous and next screen windows:

#aterm bindings
bindkey "^[[c" next
bindkey "^[[d" prev
bindkey "^[Oc" next
bindkey "^[Od" prev

#putty bindings
bindkey "^[OC" next

bindkey "^[OD" prev

#some other term, don't remember which
bindkey "^[[5C" next
bindkey "^[[5D" prev

You should be able to map ctrl-tab in a similar manner.

Oh, and check out this screenrc magic:

termcapinfo xterm "ks=E[?1lE:kuE[A:kd=E[B:kl=E[D:kr=E[C:kh=E[5~:kH=E[F"
hardstatus alwayslastline "%{-b gk}%-w%{+b kg}%50>%n %t%{-b gk}%+w%<"

(that is three lines in case it wraps - one starting with termcapinfo, second starting with "ks=, third starting with hardstatus.)

Try it out, you'll probably not be able to live without it.  It displays a status line at the bottom of the terminal which shows what window you're in and a list of the other windows.  You'll probably want to start giving your windows names at that point.  Do that via ctrl-a A, and then typing the name.

[ Parent ]

Trick for transfering files using only terminal. (3.00 / 5) (#173)
by Tezcatlipoca on Sun Mar 14, 2004 at 07:39:35 PM EST

That is right, you have two machines, you only have access to the terminal servers through serial lines (not uncommon in modern datacenters) and you need to transfer medium sized files (don't try this wirh your 100GB MP3 collection).

Using screen define a new buffer file, then use uuencode in the first machine:

uuencode file file

and go to sleep.

Next day (or week :-) )  go to the next machine and try:

cat - <<EOF >> file.uu

at this point type Ctrl-a ] which pastes screen's buffer, once finished type EOF and CTRL-D

now you can

uudecode file.uu

and you get your file in all its glory.

This trick saved me one week of internal bureaucracy....

Might is right
Freedom? Which freedom?

ReTrick for transfering files using only terminal. (none / 0) (#190)
by akuzi on Thu Apr 01, 2004 at 07:10:12 PM EST

You can also do a similar trick with 'script'.

[ Parent ]
wooWOO (2.50 / 2) (#177)
by pytholyx on Mon Mar 15, 2004 at 01:56:29 PM EST

I had a friend who couldn't shut up about this, and told me I'd love it. I've been waiting for an overview like this to be delivered right to me, I guess. Best. Program. Ever. Can't be a console ninja without this.

Desirability follows utility.
Kinda sorta like gnuserv (none / 0) (#179)
by Akhasha on Wed Mar 17, 2004 at 01:20:29 AM EST

I have an emacs habit and also couldn't live without screen. Emacs has a sorta-similar function called gnuserv, so you start it up somewhere (possibly either using nohup or in a screen session), run gnuserv-start or have it in your .emacs/custom.el. Then either background it or detach from the screen session, and from elsewhere you can access the same editing session with all the buffers preserved by logging into that machine and running gnuclient. Even though the way I run it, emacs is running in a terminal, if DISPLAY is set in the terminal running gnuclient, you get an X window. Its not entirely perfect, I've occasionally seen xemacs lock up running this way, but in general it has saved me a lot of bother and gives me a persistent development environment whereever I can ssh onto the net. Just remember that C-x C-c will exit the parent emacs, when you want to exit your editing window and leave the remote editor running use C-x 5 0

There is however one big fat caveat with using screen on linux, I have had my beautiful, 15 odd terminal screen session lock up irretrievably more than once in the past. The closest I got to tracking down the bug was some comments in a kernel list mentioning an obscure bug in the pty driver code. That may have been resolved as it hasn't happened in 6 months and I use screen every day.

my screenrc (none / 0) (#182)
by freddie on Wed Mar 17, 2004 at 04:51:09 PM EST

Using control-A messes up bash line editing, i prefer to use control-t instead

shell /bin/bash
escape ^Tt

Imagination is more important than knowledge. -- Albert Einstein

Screen under cygwin on windows (none / 1) (#185)
by askey on Fri Mar 19, 2004 at 07:06:15 AM EST

Does it work under cygwin on windows?

Yes (none / 0) (#196)
by wurp on Tue Dec 13, 2005 at 10:49:26 AM EST

I had the same question, and looked around some.  On the first implementation I found, "screen -r" didn't work consistently.

Then I found http://home.tiscali.de/emilio.lopes/screen/screen.html, which seems to work just fine consistently.

Hope that helps!
Buy my stuff
[ Parent ]

Blast from the Past (none / 0) (#186)
by Waldo on Sun Mar 21, 2004 at 02:17:43 AM EST

screen was the way to go back when SLIP was the preferred method of connecting to the Internet, the WWW was just some thing Tim BL was playing with at CERN, and command-line access was the only way to fly.  I could initiate a zmodem transfer to transfer a file onto my home computer while downloading a file through FTP to my shell account and also running a search in WAIS.  It was totally cool.

But...uh...that was 1992.  Now, I have a GUI.  No screen for me.

-Waldo Jaquith

multiplexing (none / 0) (#188)
by Torako on Sun Mar 21, 2004 at 07:31:14 AM EST

Actually, I find screen most useful when using both the GUI and virtual terminals. For example, when compiling programs I usually like to use a standard virtual terminal, because compiling might take a few hours and I don't know how often I'll be logging off and back on to GNOME in the meantime.

So I run screen and my compile process on VT1 and run "screen -x" in a GNOME terminal to monitor the progress without having to switch between X and textmode all the time (it always takes a few seconds to switch graphics modes).

[ Parent ]

screen is essential for heavy irc use (none / 0) (#189)
by akuzi on Thu Apr 01, 2004 at 06:45:32 PM EST

It lets you sit on an irc channel forever and yet connect in from anywhere on the net, scroll back to set what has been happening on the channel etc.

Run bitchX or irc2 under a screen session on a stable server that you can ssh to. Then detach and reattach whenever you need to.

Detaching sessions (none / 0) (#191)
by tim on Fri Apr 16, 2004 at 04:31:31 PM EST

I absolutely loved screen back in my university days.  I would be hacking at the lab at school until it was late enough that I wanted to go home.  Then I would just detach my screen, go home, login and reattach the screen and I would be right back in the same place.  Sadly I don't find much use for it these days.
... --- ...
GNU screen and SSH (none / 0) (#192)
by tbc on Tue Apr 20, 2004 at 04:26:04 PM EST

See my writeup at my blog: GNU screen and SSH

funny (none / 1) (#193)
by keleyu on Mon Mar 21, 2005 at 02:42:27 AM EST

lyrics lyrics

Shameless plug of another HowTo (none / 1) (#195)
by cprior on Tue Nov 29, 2005 at 06:43:30 AM EST


Different to all those text-based HowTos I tried to visualize GNU Screen as well: Towards the end of the HowTo there is an animated .gif If you find something improvable, please do not hesitate to do so!

GNU Screen: an introduction and beginner's tutorial | 196 comments (166 topical, 30 editorial, 5 hidden)
Display: Sort:


All trademarks and copyrights on this page are owned by their respective companies. The Rest 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!