Now some might say this is a silly blog post, especially since I have an Opengear 5004 console server. At this stage I haven’t explored all its uses so it is not in “production” at home.
I currently SSH home to use my lab and screen a console cable into my SRX for these lab posts. By default I have a timer on SSH sessions. Unfortunately Screen doesn’t disconnect. On Linux I’d use byobu for screen emulation but I have got this installed on my OSX box.
I was getting the error that the resource was busy. Painful. I initially was rebooting because I am a bit of a noob but thought there was a better way. I found it. Check this out.
telaranrhiod:~ pandom$ telaranrhiod:~ pandom$ screen -ls There is a screen on: 322.ttys000.telaranrhiod (Attached) 1 Socket in /var/folders/m7/m7mJ021cEgCxTMyOSAkHrk+++TQ/-Tmp-/.screen.
Here I confirm current screen sessions. Now, to kill Screen session 322.
telaranrhiod:~ pandom$ screen -X -S 1 Please specify a command. telaranrhiod:~ pandom$ screen -X -S 1 kill No screen session found. telaranrhiod:~ pandom$ screen -X -S 322 kill
Now to access my device again
telaranrhiod:~ pandom$ screen /dev/tty.PL2303-0000101D [email protected]> [email protected]>
There we go. Access again. Due to the fact I am playing with screens and firewall rules, having console access is good. For now, screen will do. I will deploy the Opengear device. Hopefully over the Christmas holidays.
I hope you have found this helpful and thank you for reading.
You could just do “screen -D -R -S 322.ttys000.telaranrhiod” to reattach to your old session 🙂
Ah ha! There you go. Thanks Geraint. My linux skills have just improved. Thanks for sharing.
Screen crash-course (for my self-reference too 😉 ):
ctrl + a c to open new window (prompt, CLI, …)
ctrl + a n to move to next window
ctrl + a p to move to previous window
ctrl + a [ to enter copy mode; hit Spacebar to mark beginning of selection, move with cursor, hit Spacebar again to mark end of selection; you can access scrollback this way too
ctrl + a ] paste what you’ve selected in previous step; works in another window too
ctrl + a x to lock session
ctrl + a ctrl +g toggle visual/audible bell (wuff-wuff!)
ctrl + a ? to get help
ctrl + a d to detach screen; re-attach with screen -r, screen -R to force-reattach
ctrl + a k to kill a window
If you happen to have “screen within screen” ie. you use screen and ssh to another machine where you run another screen, single ctrl + a [somekey] binds to ‘first’ screen, ctrl + a a [somekey] binds to ‘second’ screen.