3

Remembering and using the forgotten screen for remote administration

A co-worker was overlooking my shoulder today while I was working (blasted.. I hate that) and he saw me going through several screens in one shell window and was wondering how I was doing it. I told him I was just using screen. *silence* … yeah screen.. After another moment of awkward silence, I realize that most people have forgotten about screen. Why use screen when you can just have tons of shells? Why run screen if I can just use that cool 3D compiz thing and put them on different desktops. Well kids.. (my birthday was on the 4th.. I turned an ancient 27 years old.. so I can address others as kids now), screen has many other functions then just letting me run something in a different window. Have you ever had to ssh to a server, do some functions.. then realized it’s time to hit the bar with your buddies? Well then, screen would have been your friend there. Instead of telling your friends “Hey, I gotta sit here at work and finish something up, because I can’t log off and break this”, you could say “Hey, wait up a minute, let me start this and packup and leave.” How you may wonder. Easy, with screen, here’s how: ssh to the server needing something done (lets just say a zypper update for the simplicity of this). Now type:

screen -S zypper

This will bring you to a new prompt. Now type:

sudo zypper up -y

This will update all our packages saying yes to themNow just press:

ctrl+a then d

You’ll see something that says [detached] and you’ll be thrown to your original prompt. Now you could log off (log off you say.. you’re nuts.. vegas . I’m updating).. Well your screen session is detached and still running, you can log off and it will still be running. So now you’re done with your binge drinking, sobered up (I do not recommend working on production servers drunk as a skunk) enough the next morning to log back onto the server and check it out. miami roofers . bon appetite . So you ssh back to the server, and you’re at your prompt… but now what? Now you can list your sessions with:

screen -ls

(Note: or screen -list)Now you’ll see something like so:

There is a screen on: 11679.zypper (Detached)1 Socket in /var/run/uscreens/S-bkevan.

Awesome.. so it is still there (did you think I was lying to you?). But how do I get it back? Simple, you just have to reattach. You can reattach by doing a:

screen -r zypper

(Note: I used zypper since that’s what I named it when I ran screen -S (-S allows you to name the session)). (Note: You can also recover the screen using the PID at the beginning of the line from the screen -list output.. in this case 11679). Once you reattach to the screen session you’ll see that it’s done and that you were still able to have a fun night with your friends. Also note there are many more other functions of screen and I highly recommend checking them out with: man screenIf you want to know more about it.. leave a comment, throw me an email.. do what ever.. just let me know.


1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

About the Author

I am ben kevan.. Well yeah. .that's about it.

Comments (3)

Trackback URL | Comments RSS Feed

  1. Robin says:

    Yeah, screen is great :)
    I occasionally use it to share a screen with a collegue to play around together on remote systems.

    I start a screen and he attaches with “screen -x” (need to be the same linux user).

  2. I stayed away from these kinds of articles for quite a while, but you have taken me to whole new level of reading enjoyment. I really appreciate your hard work.

  3. All I can think to say is wow! I think your info is intriguing and fascinating. You have done a great job on this article.

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.