Linux Screen Tutorial and How To

Call Sales: 877-435-2445

Linux Services

Blog

Linux Screen Tutorial and How To

Posted by Jeffrey Huckaby 01/01/2008

Using Linux Screen for Session Management

Lost your shell connection? Need multiple shell sessions?

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.

Linux Screen for Session Management!

Screenshot of Linux Screen Terminal

Linux Screen showing the GNU page for Linux Screen Itself

Linux Screen Can Save you from that Lost Connection

What is Screen for Linux?

As the man page states, “Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).” This can be a life saver when working on your dedicated server. Screen has a several great features for helping you administer your server more productively and safely. I am going to discuss the three features (multiple windows, logging, sessions) that I use the most. Once you mastered screen, you may want to check out our 12 Point Server Maintenance Checklist and put your new found skills to use.

Installing Screen on Linux

Chances are that you already have screen on your system. On most Red Hat distributions you can find it in /usr/bin/screen. To see if screen is in your path, you can use the which command:

[admin@ensim admin]$ which screen

If you do not have screen, then you can install it easily from an RPM or the package file for your system. On Cobalt Raq servers, you can safely use the RedHat RPMS appropriate for your system.
Screen RPMs: rpmfind
Screen Web site: GNU Screen

As you probably already have screen or can use an RPM, I am not going to cover the building of screen from source. Lets get on to how to use screen.

Using Screen

Screen is started from the command line just like any other command:

[admin@gigan admin]$ screen

You may or may not get a text message about screen. If you do not, then you probably think nothing has happened, but it has. You are now inside of a window within screen. This functions just like a normal shell except for a few special characters. Screen uses the command “Ctrl-A” as a signal to send commands to screen instead of the shell. To get help, just use “Ctrl-A” then “?”. You should now have the screen help page.

Screen key bindings, page 1 of 2.
               Command key:  ^A   Literal ^A:  a
break      ^B b       lockscreen ^X x       reset      Z         
clear      C          log        H          screen     ^C c      
colon      :          login      L          select     " '       
copy       ^[ [       meta       a          silence    _         
detach     ^D d       monitor    M          split      S         
digraph    ^V         next       ^@ ^N sp n suspend    ^Z z      
displays   *          number     N          time       ^T t      
fit        F          only       Q          title      A         
flow       ^F f       other      ^A         vbell      ^G        
focus      ^I         pow_break  B          version    v         
help       ?          pow_detach D          width      W         
history            prev       ^P p ^?    windows    ^W w      
info       i          readbuf    <          wrap       ^R r      
kill       K          redisplay  ^L l       writebuf   >         
lastmsg    ^M m       remove     X          xoff       ^S s      
license    ,          removebuf  =          xon        ^Q q      
                 [Press Space for next page; Return to end.]

Key bindings are the commands the screen accepts after you hit “Ctrl-A”. You can reconfigure these keys to your liking using a .screenrc file, but I just use the defaults. The power of screen will become obvious, especially if you need to bounce around to different file system locations and leave processes running. For example, when I go in to clean out wasted disk space, I can remove files in one screen while hunting for other files in another.

Multiple Windows

Screen, like many windows managers, can support multiple windows. This is very useful for doing many tasks at the same time without opening new sessions. As a systems manager, I often have four or five SSH sessions going at the same time. In each of the shell, I may be running two or three tasks. Without screen, that would require 15 SSH sessions, logins, windows, etc. With screen, each system gets its own single session and I use screen to manage different tasks on that system.

Another trick I use is when I am editing configuration files. For example, if I want to harden SSH, I can cat out the configuration file in one window and then edit it in another.

To open a new window, you just use “Ctrl-A” “c”. This will create a new window for you with your default prompt. For example, I can be running top and then open a new window to do other things. Top stays running! It is still there. To try this for yourself, start up screen and then run top. (Note: I have truncated some screens to save space.)

Start top

  Mem:   506028K av,  500596K used,    5432K free,       
    0K shrd,   11752K buff
    Swap: 1020116K av,   53320K used,  966796K free        
              393660K cached
     PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %ME
     6538 root      25   0  1892 1892   596 R    49.1  0.3
     6614 root      16   0  1544 1544   668 S    28.3  0.3
     7198 admin     15   0  1108 1104   828 R     5.6  0.2

Now open a new window with “Ctrl-A” “c”

[admin@ensim admin]$ 

To get back to top, use “Ctrl-A “n”

   Mem:   506028K av,  500588K used,    5440K free,       
    0K shrd,   11960K buff
    Swap: 1020116K av,   53320K used,  966796K free        
              392220K cached
     PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %ME
     6538 root      25   0  1892 1892   596 R    48.3  0.3
     6614 root      15   0  1544 1544   668 S    30.7  0.3

You can create several windows and toggle through them with “Ctrl-A” “n” for the next window or “Ctrl-A” “p” for the previous window. Each process will keep running while your work elsewhere.

Leaving Screen

There are two ways to get out of screen. The first is just like logging out of a shell. You kill the window with “Ctrl-A” “K” or “exit” will work on some systems. This will kill the current windows. If you have other windows, you will drop into one of those. If this is the last window, then you will exit screen.

The second way to leave screen is to detach from a windows. This method leaves the process running and simple closes the window. If you have really long processes, you need to close your SSH program, you can detach from the window using “Ctrl-A” “d”. This will drop you into your shell. All screen windows are still there and you can re-attach to them later. This is great when you are using rsync for server migration.

Attaching to Sessions

So you are using screen now and compiling that program. It is taking forever and suddenly your connection drops. Don’t worry screen will keep the compilation going. Login to your system and use the screen listing tool to see what sessions are running:

[root@gigan root]# screen -ls
There are screens on:
        31619.ttyp2.gigan       (Detached)
        4731.ttyp2.gigan        (Detached)
2 Sockets in /tmp/screens/S-root.

Here you see I have two different screen sessions. To re-attach to a session, use the re-attach command:

[root@gigan root]#screen -r 31619.ttyp2.gigan

Just use screen with the -r flag and the session name. You are now re-attached to the screen. A nice thing about this, is you can re-attach from anywhere. If you are at work or a clients office, you can use screen to start a job and then logout. When you get back to your office or home, you can login and get back to work.

Screen Logging

As a consultant, I find it important to keep track of what I do to someone’s server. Fortunately, screen makes this easy. Using “Ctrl-A” “H”, creates a running log of the session. Screen will keep appending data to the file through multiple sessions. Using the log function is very useful for capturing what you have done, especially if you are making a lot of changes. If something goes awry, you can look back through your logs.

Linux Screen Tips

Just wanted to mention to other cool tricks you can do with screen. Screen can monitor a window for activity or lack thereof. This is great if you are downloading large files, compiling, or watching for output. If you are downloading something or compiling, you can watch for silence. To start the monitor, go to the screen you want to monitor and use “Ctrl-A” “M” to look for activity or “Ctrl-A” “_” to monitor for silence. Then open or switch to a new window. When the monitor detects activity or silence, you will get an alert at the bottom with the window number. To quickly go to that window, use “Ctrl-A” “ (thats a quote mark, ctrl-a then a “). After you do this, just type in the number of the window and enter. To stop monitoring, go to that window and undo the monitor with the same command. For example, to stop monitoring for activity you would use “Ctrl-A” “M” again.

Screen is a great tool and I use it daily for tasking ranging from hardening ssh against brute force attacks to deploying Nginx web server for a client.

Reference

Screen was covered recently in Linux Magazine by Adam Lazur (Jan 2003, Issue 105). Much of his information was adapted for this rackTIP. Other information was collected from the man pages.

Jeffrey Huckaby About Jeffrey Huckaby

Jeff is the CEO and founder of rackAID. He has been working in hosting industry since the days of Rackshack's famed customer appreciation parties back in the early 2000's. Jeff is an avid cyclist, wine enthusiast, and admitted Kraftwerk listener (please don't hold that against him). You may spot him at any number of hosting, startup and small business conferences. You can catch me on or Twitter.

Comments

maks commented on Linux Screen Tutorial and How To

maks · 11/19/2009 05:10 am

Fyi, you can attach with just the pid i.e. “screen -r 12345”

Great tut!

How 2 dev commented on Linux Screen Tutorial and How To

How 2 dev · 11/24/2009 10:49 am

I used to work with nohup until some problems with it made me use screen which is far better from nohup.By the way nice post especially for newbies.

Julian commented on Linux Screen Tutorial and How To

Julian · 12/07/2009 06:32 pm

Thanks for tutorial! Close (x) will close screen on not ?

rackAID commented on Linux Screen Tutorial and How To

rackAID · 12/08/2009 09:51 am

I typically just exit from the screen by typing “exit”.

lockedout commented on Linux Screen Tutorial and How To

lockedout · 12/22/2009 11:27 pm

Installed screen on an ubuntu server and couldn’t log back in.

Guessing it messed up some pam config.

Searching for anything with “screen” in it is an exercise in aggravation.

chusty commented on Linux Screen Tutorial and How To

chusty · 01/24/2010 07:24 am

I have screen installed on 3 or 4 dedicated servers ... it’s silly but on one of them I have a bar in the bottom of it - which is very handy… and don’t know how to turn it on on the rest of my servers :)

coskan commented on Linux Screen Tutorial and How To

coskan · 02/08/2010 06:51 pm

extremely helpful and definitive. thank you for sharing

Laetitia commented on Linux Screen Tutorial and How To

Laetitia · 02/18/2010 04:27 pm

I am using ssh and screen to work remotely on a linux server with my macbook. It works quite well to some extend. The only problem I have is that there is nothing like “Ctr-A” on a mac keyboard. So I cannot use “K”, “p” and “n” directly. Does anybody know what shortcut I need?
Thanks.

Johan commented on Linux Screen Tutorial and How To

Johan · 03/09/2010 09:55 am

@Laetitia - I use a macbook (intel osx 10.4) and have no trouble… im pretty sure you will find a “Ctrl” key on your mac keyboard, somewhere to the left of space bar and below your shift key.
http://images.apple.com/keyboard/images/gallery/wired_1_20070813.jpg

garvald commented on Linux Screen Tutorial and How To

garvald · 03/09/2010 06:46 pm

laetitia - mac keyboards have a “ctrl” key and of course the “a”  key - surely you dont mean that?

Juli Zurovec commented on Linux Screen Tutorial and How To

Juli Zurovec · 03/15/2010 10:20 am

We just got our first Mac in our office last week.  Will have to ask our new staff member how to do it.

Radu D commented on Linux Screen Tutorial and How To

Radu D · 03/18/2010 06:52 am

There is any way to run this tool on a linksys router wrt54GL with dd-wrt firmware on it?

Richard commented on Linux Screen Tutorial and How To

Richard · 03/19/2010 09:49 am

Instead of using Ctl-A for commands, I use the backtick key (key to the left of the ‘1’ key).
To do this I entered the following commands into my .screenrc file:
defescape ``
escape     ``
(those are 2 backticks for each entry)
Now to create a new screen window, all I have to enter is `c.
Great write-up.  Just enough for me to go and find additional information & uses for the screen command.

John Doyle commented on Linux Screen Tutorial and How To

John Doyle · 04/01/2010 12:10 pm

Nice I used this to run fsck and remote back in later on from home as it requires user input and you cannot use nohup with fsck easily if you want user input to fix errors etc.
Thanks

supi007 commented on Linux Screen Tutorial and How To

supi007 · 04/09/2010 04:05 am

This is a good tutorial. Thx.

jacco commented on Linux Screen Tutorial and How To

jacco · 04/15/2010 04:54 am

chusty: Add “hardstatus alwayslastline” to your .screenrc

dsb45 commented on Linux Screen Tutorial and How To

dsb45 · 05/01/2010 05:32 pm

Hi,
What about env variables with screen command ?  Do you export all you need in new window, or what procedure should one follow ?
Thanks !

quenenni commented on Linux Screen Tutorial and How To

quenenni · 05/03/2010 02:22 pm

Thanks for your article. I discovered control keys I didn’t know. The logging thing sounds great.

2 points I wanted to add:
Another nice thing with screen is that several access can be done at the same time.
That means several people can connect to the same screen and see live what others are doing.
Great stuff when ie you want to explain how something is working.. a bit like a live tuto.

And you can also use the .screenrc file to change the way it shows the sessions. Ie, all the active sessions are shown at the bottom and colored, you can give them a name, you can choose the number of sessions to launch when starting screen and execute a command in these sessions, like a ssh tunnel or a monitoring software.
you can greatly improve the layout of screen by changing them.

As it was someone who gave me that config file, I don’t know what options exactly do these tricks.
If you are interested to have mine to analyse the options, contact me.

Matthew Kress commented on Linux Screen Tutorial and How To

Matthew Kress · 05/21/2010 06:43 am

quenenni, I would love to see you config file.  Could you please post it?

Alex commented on Linux Screen Tutorial and How To

Alex · 05/21/2010 08:15 am

Thank you, a great article, very helpful!

mehrdad commented on Linux Screen Tutorial and How To

mehrdad · 05/24/2010 04:50 pm

Thanks, It was very helpful.

Mech commented on Linux Screen Tutorial and How To

Mech · 06/07/2010 01:09 pm

Thanks, extremely well writen

dsb45 commented on Linux Screen Tutorial and How To

dsb45 · 06/07/2010 07:17 pm

quenenni,
I would also be interested in seeing
your config file.  As Matthew requested, can you post it, or a url to where we can view it ?  Thanks for your input.

quenenni commented on Linux Screen Tutorial and How To

quenenni · 06/09/2010 06:59 pm

Yop yop..

I sent the file to the website owner already few weeks ago, but it seems something went wrong.

Anyway, here it is:
http://quenenni.domainepublic.net/screenrc.txt
Put it in the home directory under the name ‘.screenrc’ .

Jeff H. commented on Linux Screen Tutorial and How To

Jeff H. · 06/10/2010 10:34 am

I know you submitted a ticket in our sales area but I never saw the other email with the screen file. I wonder if the security system flagged it or someone else here deleted by mistake. Thanks for posting it again.

steevo commented on Linux Screen Tutorial and How To

steevo · 06/18/2010 05:13 am

Thanks a lot, a friend showed me once how to use screen, and this is a great refresher/reference. It should be installed as default when you apt-get ssh-server

Matthew Wilcoxson commented on Linux Screen Tutorial and How To

Matthew Wilcoxson · 06/29/2010 11:20 am

Yep, screen is a really useful tool.

At the moment I use the enhanced version called “byobu”, which adds a cool bar at the bottom of the window with useful information. (That’s probably what @chusty has found)

Aaron commented on Linux Screen Tutorial and How To

Aaron · 07/07/2010 04:47 am

This tutorial is very clear and really helpful.  Sometimes there are just a few small things that you need to get over a learning curve and this did it for me.
I am using screen on my Dreamhost hosted site to run Nodejs to experiment.  I can log out of my ssh session and node is still chugging along.  Thank you!

Jeff H commented on Linux Screen Tutorial and How To

Jeff H · 07/07/2010 09:28 am

Glad you liked our tutorial.  I think there are some newer tools out there, but I always fall back on screen for its simplicity and easy of use.

gkokmdam commented on Linux Screen Tutorial and How To

gkokmdam · 08/12/2010 02:49 am

Just great! Specially thanks to @quenenni for your .screenrc !

Lakshmi Naarayanan commented on Linux Screen Tutorial and How To

Lakshmi Naarayanan · 08/30/2010 10:02 am

Hi Jeff,

Useful tutorial - I’ve had the screen die on my occasionally (once in 2-3 months or so) - I am left helpless when it dies, basically all record of which machines I logged into etc are lost. Is there any way to resurrect a dead screen? Or port an existing screen to a different machine? I am looking for some way to recover a session either from its dead state or from another machine with a history file or something like that..

Jeff H commented on Linux Screen Tutorial and How To

Jeff H · 08/30/2010 10:44 am

What is being shown with screen—list?
If it is listed as attached, you can use:

screen -x -R

and it will force detach the screen.  If it is listed as dead, the socket is no longer active and it cannot be recovered.

Adam Kleiner commented on Linux Screen Tutorial and How To

Adam Kleiner · 09/12/2010 02:01 pm

Cool. Will have to try it out!

Gambakoker commented on Linux Screen Tutorial and How To

Gambakoker · 09/16/2010 09:49 am

Fantastic tutorial / HowTo! Clear and simple. I searched a while for a good one like yours. Thank you very much.

Chepech commented on Linux Screen Tutorial and How To

Chepech · 09/28/2010 04:44 pm

The Num Pad on my keyboard doesnt work with screen, also my keyboard layout is lost, but as soon as I close it, it gets back to normal, any ideas?

Gaurav commented on Linux Screen Tutorial and How To

Gaurav · 10/28/2010 04:43 am

Thanks for writing this up! It was very helpful.

Lorraine commented on Linux Screen Tutorial and How To

Lorraine · 11/30/2010 10:34 pm

Haha, your intro paragraph summed up exactly how I used to feel before I discovered screen.

TuffRank commented on Linux Screen Tutorial and How To

TuffRank · 12/04/2010 07:33 pm

Kool info, very useful indeed….

Jeff H commented on Linux Screen Tutorial and How To

Jeff H · 12/06/2010 10:45 am

Thanks for the feedback. I should probably do a screen tutorial part 2.  I never imagined when I first wrote this years ago it would be so popular.

ye commented on Linux Screen Tutorial and How To

ye · 12/17/2010 04:19 pm

great tutorial

Fort Collins commented on Linux Screen Tutorial and How To

Fort Collins · 12/19/2010 03:50 pm

Perfect. Most screen tuts didn’t point out that you need to press CTRL+A THEEEN another key.. Thanks for the post.

sam commented on Linux Screen Tutorial and How To

sam · 01/12/2011 06:42 pm

Excellent article.
I heard screen from watching support work remotely.  They actually maximized my putty and had 3 prompts going at the same time.  one was counting and the other two were tail -f of different logs.  I have been trying to recreate that using CTRL+A f   this splits the screen but does not give me another prompt.  Any thoughts on what I am doing wrong?
thanks for the excellent article!

dhina commented on Linux Screen Tutorial and How To

dhina · 01/19/2011 04:21 am

Thanks for the nice article.

@quenenni you mentioned “That means several people can connect to the same screen and see live what others are doing.”

can you tell how to do this

Jeff H. commented on Linux Screen Tutorial and How To

Jeff H. · 01/19/2011 10:42 am

To join a screen that is already attached, use:
screen -x screenid
You can get the screen ID number using list:
[root@gigan ~]# screen -list
There is a screen on:
      29878.pts-6.gigan     (Attached)

screen -x 29878.pts-6.gigan
Will attach you to that screen. Both users have control so be careful.

I use this when training or reviewing staff.

Cezar commented on Linux Screen Tutorial and How To

Cezar · 03/12/2011 07:51 pm

Best screen tutorial on the net!

JesseTaylor commented on Linux Screen Tutorial and How To

JesseTaylor · 03/13/2011 03:23 am

Great intro. I was just starting to play around with screen, and yours was the first tutorial that came up on Google (I see why!). Thanks for putting this together.

Sparx commented on Linux Screen Tutorial and How To

Sparx · 03/13/2011 02:10 pm

Thanks for this tutorial! It helped me so much, this is EXACTLY what I needed :)

Chantu commented on Linux Screen Tutorial and How To

Chantu · 04/04/2011 04:15 am

Dear Jeff

Awesome tutorial. I have been using Screens for last 6+ years and it works great. I leave all my windows as it is and next day i get my work as it is. Saves me lot of times.

Recently i was stuck on screen as it went in silent monitoring mode and i was not aware of it. I came here and learned about how to use silent monitoring.

Thanks a lot for this.
Regards
Chantu

Cubicle Generation commented on Linux Screen Tutorial and How To

Cubicle Generation · 04/07/2011 12:49 am

Hands down the best intro to screen tutorial I’ve seen :bowdown: I wish I had this as a primer when I was trying to figure screen out.

Mike commented on Linux Screen Tutorial and How To

Mike · 04/24/2011 02:34 pm

The Linux command to obtain help screen for the rm command is

mimi commented on Linux Screen Tutorial and How To

mimi · 06/03/2011 06:09 am

hello,
could you please tell me how can i run a matlab code in screen?

jaime commented on Linux Screen Tutorial and How To

jaime · 07/05/2011 04:05 pm

Thank you it was great

SaschaK commented on Linux Screen Tutorial and How To

SaschaK · 07/23/2011 04:06 am

Great Tutorial, great tool! This will help me monitoring/maintaining root servers. Thanks for sharing!

Purab commented on Linux Screen Tutorial and How To

Purab · 08/09/2011 01:25 pm

That was fast and useful ! No unrequired detail.

Nick Yeoman commented on Linux Screen Tutorial and How To

Nick Yeoman · 08/27/2011 04:16 pm

I knew what screen was and what it did, but until this article I wasn’t proficient in using it.  Thanks so much!

FZambia commented on Linux Screen Tutorial and How To

FZambia · 09/08/2011 02:02 am

Thank you so much, your tutorial is great!

Arvent commented on Linux Screen Tutorial and How To

Arvent · 09/11/2011 09:01 am

Thank you very much. It’s surely enlightening.

Digit commented on Linux Screen Tutorial and How To

Digit · 09/23/2011 01:25 am

Don’t mean to necro an old post, but thought it was worth noting you are still getting hits on this great how to.
Excellent work!

Jeffrey Huckaby commented on Linux Screen Tutorial and How To

Jeffrey Huckaby · 09/23/2011 09:09 am

Thanks for the feedback.  Fortunately, screen does not change much and I still use it almost daily.

Sharad commented on Linux Screen Tutorial and How To

Sharad · 09/26/2011 05:31 am

Thanks for info, it was helpful

Thomas Ding commented on Linux Screen Tutorial and How To

Thomas Ding · 09/29/2011 09:30 pm

Dear Jeff.,

Awesome tutorial. I had learn much from this article.

I have a idea about the activity monitor. Since screen can monitor the activity or silent in a windows, is it possible to invoke a user specified script or command when the silent was detected?

If it is possible, we can get the information as soon as possible.

Thank you very much.

minesh commented on Linux Screen Tutorial and How To

minesh · 10/01/2011 04:45 am

Nice Article to get started with screen.
I love it.

Thanks

Ian commented on Linux Screen Tutorial and How To

Ian · 10/05/2011 01:23 pm

good post.. let me get into screen in 10mins. :)

Eduardo commented on Linux Screen Tutorial and How To

Eduardo · 10/07/2011 03:40 am

Hello and thanks for the article. I use linux screen at work, but not long ago I moved to the Mac. The big problem is that it is not possible to use the mac keyboard to do simple Screen command (like ctrl+right arrow) for moving to the next screen or work with different tabs. Does anybody knows a way/tutorial/application to use linux screen command as in linux or Windows through Putty? Thanks in advance.

jeff commented on Linux Screen Tutorial and How To

jeff · 10/17/2011 03:37 pm

Great tutorial on screen - we’re just about to post a shorter tutorial on screen on our blog. (and no worries - we didn’t lift any ideas) ...check out our open source blog @ www.digitalboundary.net/wp

Thanks!
JG

Event Horizon commented on Linux Screen Tutorial and How To

Event Horizon · 10/25/2011 07:09 pm

Highly recommended - a very clear and concise tutorial.

E. commented on Linux Screen Tutorial and How To

E. · 11/02/2011 07:47 pm

Wow, I never used screen before but I wonder how I did it. Found this by google, managed to find the essentials in a couple mins, great one, thanks!!!

Miki commented on Linux Screen Tutorial and How To

Miki · 12/23/2011 03:11 am

We run several screen instances from one box, eg. :
27185.pts-53.CentOS-57-64-minimal     (Detached)
27209.pts-53.CentOS-57-64-minimal     (Detached)
27281.pts-53.CentOS-57-64-minimal     (Detached)

Is there a way to ‘name’ a screen id, so instead of having to remember
the exact PID, i use screen -x 1 for pid 27185, screen -x 2 for pid 27209 and screen -x 3 for pid 27281 ??

chip commented on Linux Screen Tutorial and How To

chip · 01/06/2012 12:09 pm

say that I have 8 screen sessions running, I attach to one of them using screen -r <pid>, how do a ‘gather’ the other 7 sessions so that I can use the full functionality of stacking the screens?

sanjayts commented on Linux Screen Tutorial and How To

sanjayts · 01/08/2012 10:35 am

@chip: Assuming you want named sessions for clarity, you can name a session in screen by starting screen as:

> screen -U -S session_name

You can then reattach to a session using:

> screen -R session_name

or kill/quit a session using:

> screen -S session_name -X quit

Hope that helps

chip commented on Linux Screen Tutorial and How To

chip · 01/09/2012 02:58 pm

@sanjayts: Thank you for responding back. I am very familiar with screen and a good deal of the the things that can can be done with it. My question is a little more out on the edge: I already have 8 separate screen sessions running and I ‘reattach’ to one with the normal method of screen -r <pid>, however, once I have that screen session attached I would like to be able to attach to the other 7 and stack them, much like we would do ctrl+a ‘c’ . In the end ‘gather’ all of these individual sessions and bring them under one roof so I can scroll through them using ctrl+a n or p (and see them listed, etc). Thanks

sanjayts commented on Linux Screen Tutorial and How To

sanjayts · 01/10/2012 02:03 am

@chip: Oops, my previous post was actually meant for @Miki but I’ll take a stab at your question.

AFAIK, there is no way of concatenating multiple screen sessions. Some recommend attaching processes to the new terminal as here http://unix.stackexchange.com/questions/21470/concatenate-two-screen-sessions but I’m not sure if that’s what you want. As a good compromise, tmux allows jumping between sessions using the ‘choose-session’ command which should at least relieve you of detaching and reattaching just to view the contents of a different session. Good luck.

Ashton commented on Linux Screen Tutorial and How To

Ashton · 01/23/2012 08:01 pm

Great tutorial, thanks! Screen is awesome.

Stefano commented on Linux Screen Tutorial and How To

Stefano · 02/07/2012 12:05 pm

I can’t reattach a session of another user being root. It’s important for me because I administer a network and often users forget “screen” sessions on the hosts. Is it possible ? Thank you.

itchy rat commented on Linux Screen Tutorial and How To

itchy rat · 02/08/2012 12:40 am

gr8 !!
Many a time my putty session disconnected during Linux patching. gr8 pain in the…
This one seems will ease my patching pains.

Love this one. Thx a lot.

convert flac to mp3 commented on Linux Screen Tutorial and How To

convert flac to mp3 · 02/08/2012 02:11 am

thank you
i’ve been having linux screen management problems for a while now,
maybe your post will help me to figure out some stuff

belgotus commented on Linux Screen Tutorial and How To

belgotus · 03/06/2012 02:38 pm

very good howto, go to basics is the best

Storm commented on Linux Screen Tutorial and How To

Storm · 03/25/2012 02:07 pm

Thanks, mate. Great tutorial.

Gretta commented on Linux Screen Tutorial and How To

Gretta · 04/03/2012 09:18 am

Thanks a lot for the tutorial, it was very useful for me since I have only recently switched to Linux… and love it so far. I will keep watching the blog for more helpful updates.

Wendy commented on Linux Screen Tutorial and How To

Wendy · 04/23/2012 06:16 am

Thanks for the great article!
I was looking to try using Screen on Linux and after reading this piece from you it looks rather simple.

Sathishkumar commented on Linux Screen Tutorial and How To

Sathishkumar · 05/08/2012 12:33 am

Thanks for the great guide.

Nasimuddin Ansari commented on Linux Screen Tutorial and How To

Nasimuddin Ansari · 05/08/2012 09:58 pm

Anyone know how to increase max number of window in a single screen session? In my setup, I can open 40 . For 41th window,  getting message “no more windows”.

Bibi commented on Linux Screen Tutorial and How To

Bibi · 06/04/2012 11:23 pm

On my Angstrom distribution screen doesn’t seem to remain active when the ssh connection drops (or is exited). screen -ls gives “no sockets”. Any idea’s how to get this working?

kk commented on Linux Screen Tutorial and How To

kk · 06/06/2012 05:16 am

i need how to search fields by using shellscript

kamal commented on Linux Screen Tutorial and How To

kamal · 08/24/2012 01:50 am

Hi, is it possible to display all the sessions in the status bar if we have more that 10 session in a single screen? The issue i see is that when i open more than 13 session the new session are getting hidden not displayed on the hard status bar. we can use ctrl-a w to see the list. I am looking for an option where we can display all the sessions (for example 20 session with tile) some thing like wrap and display the new windows created in the 2nd line on the hard status bar.

Erez commented on Linux Screen Tutorial and How To

Erez · 08/31/2012 12:54 am

The name of the software is “GNU Screen”, not “screen” and definitely not “Linux screen”. By calling it that you’re mis-attributing the software and misleading your readers.

Joel commented on Linux Screen Tutorial and How To

Joel · 11/02/2012 07:36 am

Fantastic tutorial - always knew that this tool existed, but never had a clear guide and path to get into it - going to be using this every day now!

Shantanu Deshpande commented on Linux Screen Tutorial and How To

Shantanu Deshpande · 11/02/2012 09:44 am

Thank You so much,

this article definitely saved several hours ...thanks

Tomek commented on Linux Screen Tutorial and How To

Tomek · 11/02/2012 09:44 am

thank you - a really nice introduction! very helpful

KP commented on Linux Screen Tutorial and How To

KP · 11/05/2012 11:45 am

@Jeff - Thank you for your efforts!  Thank you for taking time out of your life to post these write ups.  Though it may be simple… from the remarks that you received after your post, it is evident that you helped people and you were on par covering the need for it. Kudos to you sir!

Dave commented on Linux Screen Tutorial and How To

Dave · 11/27/2012 12:47 pm

Arghhh…. happily using cygwin and getting kicked off regularly.
Ran this screen as it is supposed to protect against that and its decided to bugger around with my settings so now I can’t scroll up and down the large screen I happily had…

kumaoni commented on Linux Screen Tutorial and How To

kumaoni · 11/28/2012 11:29 pm

This tutorial is so cool.. opens a whole new world to managing my linux wiindows, thanks Jeffrey !!

Geoffrey Hoffman commented on Linux Screen Tutorial and How To

Geoffrey Hoffman · 11/29/2012 01:20 pm

I have to agree with everyone else here. This is a great overview tutorial for newbies like me. I have a feeling I will be back here many times. Bookmarked!

Antony commented on Linux Screen Tutorial and How To

Antony · 02/11/2013 12:28 pm

No, it’s not GNU. I have the 4th Berkeley distribution, and it’s just called ‘screen’ version 4.0.2. According to the man-page:

Its roots are a merge of a custom version 2.3PR7 by Wayne Davison and several enhancements to Oliver Laumann’s version 2.0. Note that all versions numbered 2.x are copy-right by Oliver Laumann.

Nothing to do with GNU.

Alex commented on Linux Screen Tutorial and How To

Alex · 02/27/2013 06:59 pm

Would I be right in assuming that this would not work well for GUI programs?  If I start SSH with the “-X” option and run a remote graphical program, then the program will still die if I should lose my connection, since the X-Windows connection has broken, right?  If not, how would I ever get back to the GUI interface?

oddsatisfied commented on Linux Screen Tutorial and How To

oddsatisfied · 03/12/2013 08:37 am

Nothing like a comment on a five-year-old blog, but I second Matthew’s recommendation for Byobu. It’s in the repos for Debian and is preinstalled in Ubuntu server. A nice feature is automatic start, so once it’s enabled I can just use it without forgetting to launch it.

Add Comment

Commenting is not available in this section entry.

SUBSCRIBE

rackAID Server Management Blog RSS Feed Follow rackAID Server Management on Twitter I Like rackAID's Server Help Contact rackAID about IT Support

Recent Blog Posts

Our Blog