Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm new to screen and I'm trying to figure out how to detach from a session and reattach later. So far I've tried:

$screen
C-a z (within screen to detach)
$screen -r

So far so good but when I C-a z to detach again, I see 2 screen processes running:

$ps
  PID TTY           TIME CMD
33145 ttys000    0:00.06 -bash
33176 ttys000    0:00.01 screen
33407 ttys000    0:00.01 screen -r

If I detach and reattach again I get another screen process, etc...

So, how can I reattach to the screen session without spawning a new process?

Thanks!

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

C-a z suspends your screen process. If your shell is bash, you can see the stopped process by running jobs and resume it with fg. Detaching is a different concept.

To detach from a session, use C-a d. You will still see the screen process in your process list, and you can list it by running screen -ls. Resume with screen -r, but read the man page about the different ways to resume a running screen session.

Congratulations on learning about screen! It's an amazing tool.

share|improve this answer
    
Thanks! screen really is amazing. I can't believe I'm just learning about it now. I ran across it while trying to find a way to do remote pair programming and now it's as ingrained in my development process as git. –  spinlock Mar 7 '12 at 16:38
add comment

Try to detach within a screen:

ctrl a d

to reattach:

screen -rd (detaches the screen first if was attached)

There is also:

screen -x (attaches the screen again, so you can watch the screen with two sessions)

share|improve this answer
2  
To elaborate: ^A z (or ^A ^Z) suspends screen (the equivalent of ^Z to most processes). ^A d (or ^A ^D)is the Detach command. To get back the screen session you suspended you need to use fg or other OS job control commands. –  voretaq7 Mar 2 '12 at 19:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.