Linux Reality Forums
Welcome, Guest. Please login or register.
November 19, 2008, 05:45:41 PM
18009 Posts in 2326 Topics by 1364 Members
Latest Member: Linuxnewbie
Home Help Search Login Register
Linux Reality Forums  |  Linux Reality Podcast  |  Linux Reality Episodes  |  Episode 49 - GNU Screen « previous next »
Pages: [1] Print
Author Topic: Episode 49 - GNU Screen  (Read 5065 times)
Chess
Administrator
*
Posts: 1069



View Profile WWW
Episode 49 - GNU Screen
« on: February 14, 2007, 04:33:52 PM »

In this episode: a few miscellaneous items, such as testing some BSD's, installing Ubuntu Edgy on a Thinkpad t42, and setting up a new server on an old P3 750mhz machine; a discussion of the basics of using GNU Screen (additional tips here and here); a listener tip on Wine; lots of great feedback including some audio comments on the Linux in schools issue.

http://www.linuxreality.com/podcast/episode-49-gnu-screen/
« Last Edit: February 14, 2007, 04:36:34 PM by Chess » Logged

jza
Full Member
***
Posts: 239


OpenOffice.org is Open for your Business


View Profile WWW
Re: Episode 49 - GNU Screen
« Reply #1 on: February 14, 2007, 07:51:02 PM »

I've heard about GNU Screen, I havent heard the show yet (is downloading) but I am really curious about triying GNU Screen. I love the CLI but I am not very knowledgable at least not to a degree I can consider myself a power user. I got a BASH book from Oreilly and I just discover all the keybindings and such. I guess once I up my skills in VIM, MC, and BASH I will be really up for some serious CLI usage.
Logged

Alexandro Colorado
OpenOffice Spanish Co-lead
lz_05
Newbie
*
Posts: 40


View Profile
Re: Episode 49 - GNU Screen
« Reply #2 on: February 15, 2007, 01:41:36 AM »

Wow! I've never heard of screen before, but it definitely fills a niche for my remote sessions. When I'm at my computer locally, I simply switch between my virtual terminals. Now, I know a great way to have better control with ssh. This is just about the best thing I have learned about the Linux CLI. Great episode!
Logged

Registered Linux User #386965
RichardBronosky
Newbie
*
Posts: 28



View Profile WWW
Re: Episode 49 - GNU Screen
« Reply #3 on: February 16, 2007, 02:57:39 AM »

I just have to PRESS this point:  GNU Screen is NOT just for remote shells!  It is a staple for anyone who uses a shell for anything.  Once you learn to use it, you realize that not using it is like loosing the ability to multitask in you window manger.  Remember how excited you were when you first learned to use tabbed browsing?  That's what Screen is like.  It's like getting to have your Firefox virginity back again.  Okay, I digress...

I think we should share some non-remote shell examples.

Here's one I use 20+ times a day.  Say I'm in the middle of writing a highly complex command which is just too l33t hax0r for any human to remember the exact syntax.  Here it is...  "chmod -"  oh no! you want to do a recursive chmod, but you can't remember if it is "-r" or "-R" what do you do?  Visit google? No, the answer would be 15 pages deep.  Launch a new shell to call "man chmod"?  No, your Beryl Window Open Effect is set to 120 seconds of "Fire".  You simply hit "Ctrl-A c" to create a new Screen "window" and call "man chmod" there.  So that was a bid sarcastic, but the concept stands.  (Let's clarify official terminology: In Screen the term for each individual TTY/shell session is "window".  When you split the screen, the results are called "regions".  Each region can display a different "window".  Either "region" can be closed without terminating the "window" that occupies it.)  I use new "windows" all the time to read man pages and when I come back to want I was doing, my scrollback context is in tact.

When I am developing a web app in vim, I have Screen split into a large region for vim, and a 5 line high region (made via "Ctrl-A :resize 5") with a "tail -f /var/log/apache/error" running in it.  That way as I save and refresh, I can see what to logs are doing.

When I am trying to compile an app from source and I find myself in dependency hell, I can "Ctrl-A c" into a new window and do a "locate lib\*.so"  to try and find the missing lib.  (this is where using "Ctrl-A Esc" to enter scrollback mode and then using vim-style searching comes in handy)  If I don't find the lib  I can do "apt-cache search" or try out the "apt-file" that Dave Yates mentioned.  The whole time I am constantly flipping back and forth between the 2 or 3 windows I am using to do this install and the scrollback context is independent and in tact for each.

Just the other day I found myself tweaking my /etc/X11/xorg.conf file in a terminal window in vim.  (Why don't I use gvim for this?  Read on...)  When I was done with my tweaking I used Ctrl-Alt-Backspace to restart gdm.  To my dismay I got the Xorg failed to start screen.  So I use Ctrl-Atl-F6 to get a login prompt and when my .bashrc fires, it lauches a in to screen attaching to the session that got detached when gdm closed the terminal.  Cool huh?  It gets better.  My xorg.conf is still open in vim, and my undo history is in tact.  I hit "u" "u" "u" as I watch all my changes slowly get undone one at a time.  I relaunch gdm several times by going into another Screen "window" and since I expect to have to do a lot of trial and error I go ahead and "su -" then do "/etc/init.d/gdm restart".  I "Edit, Restart, Repeat" until I get back into Gnome.  When I launch the terminal, hey look it's my Screen session!  So I drag-resize the terminal to fill about 1/3 of the monitor and launch a browser to fill the other 2/3.  I'm researching and editing nicely.  But for part of this I want more Terminal workspace.  So I rotate my cube (switch desktops) and launch a new terminal and make it fullscreen with F11.  <voice="Stan's bored 'you killed Kenny' style">Hey look, it's my Screen.</voice>  I edit in the same vim until I need my browser, at which time I flip back and transcribe something from the browser page into the config file.

You can see how Screen is good for much more than remote shells right?  I could spend all day talking about how much I use screen.  Once you master using the split screens, scrollback, and copying/pasting... you'll never want to use a shell without Screen.
Logged


"I just can't figure out how you guys are making those cool look'n glassy buttons!"
jza
Full Member
***
Posts: 239


OpenOffice.org is Open for your Business


View Profile WWW
Re: Episode 49 - GNU Screen
« Reply #4 on: February 16, 2007, 03:05:57 AM »

Quote
I just have to PRESS this point:  GNU Screen is NOT just for remote shells!  It is a staple for anyone who uses a shell for anything.  Once you learn to use it, you realize that not using it is like loosing the ability to multitask in you window manger.  Remember how excited you were when you first learned to use tabbed browsing?  That's what Screen is like.  It's like getting to have your Firefox virginity back again.  Okay, I digress...

How relevant is screen 'tabed' hability now that we usually run the CLI on konqueror  or gnome-terminal and we have tabed shell.
Logged

Alexandro Colorado
OpenOffice Spanish Co-lead
RichardBronosky
Newbie
*
Posts: 28



View Profile WWW
Re: Episode 49 - GNU Screen
« Reply #5 on: February 17, 2007, 04:57:30 PM »

How relevant is screen 'tabed' hability now that we usually run the CLI on konqueror  or gnome-terminal and we have tabed shell.

It's totally relevant.
1.  Workflow consistency.  For the same reason I caution people from remapping everything they use in vim to custom keystrokes.  When you find yourself without your crutches, you are gimped.  If you learn to rely on your tabbed terminal app, then when you do SSH into a remote box and need to have Gnu Screen skills to get the job done the fastest way possible... you won't have the skills.
2.  As I explained in one example, you can have your terminal or even your window manager crash and when you go into your terminal again (even if only by Ctrl+Alt+F[1-6]) you have everything (including the tabs that you would have lost) intact.  If you had a vim session, kernel compile bit torrent dowload, etc going...  It wouldn't be lost.
3.  Have you ever been working on Machine A and had some kind of lockup that forced you the SSH in from Machine B to try to fix it?  If you are a Gnu Screen user, when you shell in from Machine B, you would have access to all the shells that you had open on Machine A before the lockup.
4.  You may say that my point #2 isn't that compelling, but if instead of working local and having your WM crash, what if you were working remotely and had a network glitch.  That's very common.
Logged


"I just can't figure out how you guys are making those cool look'n glassy buttons!"
RichardBronosky
Newbie
*
Posts: 28



View Profile WWW
Re: Episode 49 - GNU Screen
« Reply #6 on: February 17, 2007, 05:03:00 PM »

Chess, you tease!  What escape sequence do you use for screen?  How do you get your terminal to start into screen?  Can you post your .bashrc and .screenrc?

Update:  I just found http://www.chessgriffin.com/files/config/

You are using backtick as your escape?  I tried that for a while, but I paste shell commands that use backticks so much that it drove me crazy.  Use escape ^@^@ which is Ctrl+SpaceBar, then If I need to nest one screen within another (for multiuser colaboration, or local Screen with a window into a remote Screen) I make that one escape ^T^T.

I'm still looking to see what you do for your Screen startup.
« Last Edit: February 17, 2007, 05:20:13 PM by RichardBronosky » Logged


"I just can't figure out how you guys are making those cool look'n glassy buttons!"
Chess
Administrator
*
Posts: 1069



View Profile WWW
Re: Episode 49 - GNU Screen
« Reply #7 on: February 18, 2007, 08:48:09 PM »

Richard, yes I use the backtick and I have not found it to be a problem.  For the screen startup, I have this in my .bashrc:

Code:
# Start Screen upon SSH
if [ "$SSH_CONNECTION" ]; then
if [ -z "$STY" ]; then
exec screen -d -R
fi
fi

I also have an alias that essentially does the same thing for when I run screen manually:

alias screen='screen -RD'

so it will automatically detach and reattach.
Logged

dozens
Newbie
*
Posts: 14


View Profile
Re: Episode 49 - GNU Screen
« Reply #8 on: March 21, 2007, 10:23:15 AM »

Just heard this episode (new subscriber).

Is it possible to use Screen while connect to a site with phpterm or some equivalent http based shell ? I won't get a chance to try it until tonight. I suspecting it to be difficult since two pieces of software will be doing some terminal manipulation.
Logged
jza
Full Member
***
Posts: 239


OpenOffice.org is Open for your Business


View Profile WWW
Re: Episode 49 - GNU Screen
« Reply #9 on: March 21, 2007, 12:47:53 PM »

I guess u will need to know if that terminal let you have a curses interface or if you use vi, try to launch a view port.

On scape mode type :vsplit and see if it can redraw the split layout.
Logged

Alexandro Colorado
OpenOffice Spanish Co-lead
dozens
Newbie
*
Posts: 14


View Profile
Re: Episode 49 - GNU Screen
« Reply #10 on: March 21, 2007, 04:11:43 PM »

I used putty to connect to a FC4 machine and created a screen session. I then detached and connected via the console to my FC4 machine and tried "screen -r" but got a message saying
Quote
Cannot open your terminal '/dev/pts/1' - please check.

I then tried "screen -D" and got
Quote
There is a screen on:

   10616.pts-2.MA17-BUILD02   (Detached)
There is no screen to be detached.

How can I reattach to this screen ?
Logged
dozens
Newbie
*
Posts: 14


View Profile
Re: Episode 49 - GNU Screen
« Reply #11 on: March 29, 2007, 02:04:09 PM »

Does anyone know if it is possible to kick of a screen session from a web page ? I was hoping to write a simple php script that did a system or proc_open command but I get a error message saying
Quote
Must be connected to a terminal.
. I want to setup a page that kicks off some background processes using screen.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Cheap Electricity - Cheap Gas - Renegade Motorhomes - Loans