BY-NC-SA: sam.d

Unlocking your SSH session after pressing ctrl+S

closeThe world moved on since this content was published 8 years 11 months 9 days ago. Exercise diligent care when following any instructions and see opinions in the time they were written. If you must have an updated version, please ask kindly through the contact page.

It happens to me on a quite frequent basis. I work in a Windows based editor for some time, and press ctrl+s every now and then to save my changes to disk. It turned kinda into a habbit. No big deal, unless… you start working in VI. Everytime, well, until now, when you press ctrl+s, it would hang up your session. Nothing you could do about it. It’s the most frustrating thing ever. You are finished with your modifications, want to save them, and instead of :wq, you accidentally, out of a habbit, hit ctrl+s. *Poof*! Gone are all your changes, you have to restart the session, and make your changes again. Well, Not anymore!

While I was reading a Gentoo tutorial on Screen to learn how I can scroll back in Screen, I learned about the lock-screen function too. It turns out, that when you press ctrl+s, you lock your Screen session. Unlocking is easy, just press ctrl+q. That’s all. I then remembered my VI issue, and immediately fired up a shell to test it. And what happens? After pressing ctrl+s your session seems to hang. Pressing ctrl+q….woooooooooot! unlocks it! I think I just found my answer to the biggest linux annoyance ever! I feel a lot more comfortable working in an SSH session now! Oh, and just for the record: no, I don’t use Gentoo as a distro, I’m a RPM-based person. But there just happened to be a nice tutorial on Screen running on Gentoo, and well, you know the beauty of Linux, if it works that way on Gentoo, it works practicly always the same way in another distro.


Filed Under: Tutorial

Tags: , , , , ,

Released: on Mar 14, 2008 under a Creative Commons Attribution-NoDerivs (CC-BY-ND) licenseCC-BY-ND

Comments (6)

Trackback URL | Comments RSS Feed

  1. actually, Ctrl-S and Ctrl-Q are not a feature of screen, but a feature of nearly any unix terminal emulation. I have no idea what these things were good for back when, but right now it’s nothing but annoying.

    Then again knowing about Ctrl-Q and not telling my coworker makes me his hero here and then when I unlock his terminal. Just don’t tell him what I’m doing :-)


  2. Gareth Gregor says:

    For years i have had this problem and for years ( like almost 10 ) i have thaught maybe i should see how to unlock it but never got around to it… Thank you.
    P.s.: Nice drupal…

  3. David Keech says:

    If you want to stop ctrl-s and ctrl-q working at all, put this in your .profile (or.bash_profile or whatever you use):

    stty -ixon -ixoff

    You can also run “stty -a” to see a list of control characters that your terminal supports.

    [webmaster edit: s/ion/in/]

  4. Anonymous says:

    It annoyed me several times. Today I found your article.
    It’s so nice now. :)

  5. Anonymous says:

    Thanks buddy!!

    I too was facing the same issue , thanks again for your help!!

  6. Maciek says:

    I suffered for years from the same problem, now I found the solution… Amazing how a simple keystroke can make life better :)

    I used to work with Emacs, and I always do ctrl-A to jump to the beginning of line, and ctrl-D to delete a character. It happens too often to hit the key between these two…