Raam Dev’s Weblog

Avatar

The secret to excelling? Stop trying so damn hard.

Recovering from CTRL+S in Putty

Every once in awhile, I’ll press CTRL+S by accident while I’m inside a terminal window. For the longest time, this simple accidental keystroke meant I had reconnect to my Linux server, kill whatever program I was running, and then start it again. Eventually I got sick of this happening and decided to do what I should have done in the first place: Google It.

Apparently CTRL-S actually does XOFF, which means the terminal will accept key strokes but won’t show the output of anything. It will appear as if your terminal is dead when it’s really just waiting to be turned back on. The fix? Simply press CTRL-Q to turn flow-control on (XON). If you pressed a whole bunch of keys before pressing CTRL+Q, you’ll see the output from those keystrokes.

In the Windows world, CTRL+S is used as the Save command. Over the years, I’ve developed the habit of pressing CTRL+S every few minutes while working on a document, simply because I’ve had too much work lost from stupid errors. Thankfully, this habit will no longer get in my way of working in the Linux world.

24 Comments, Comment or Ping

  1. xian

    Yes!!!! Thanks so much! I imagined this was a simple issue, but my previous attempts at screaming and banging on the keyboard failed to elicit the magic Ctrl-Q combination…

  2. Haha, I’m glad this helped you! It drove me crazy for many months too. I just couldn’t believe it was so easy to crash a terminal session and I didn’t want to unlearn my habitual “Ctrl+S” habit for fear of losing work later on down the road.

  3. nissou

    wicked, cheers! This has been bugging me for a while.

  4. Nitin

    phew!!!
    thanks so much…. i was fed up with this since morning…. can’t help pressing ctrl-s to save a file i’m editing

  5. Thanks! Been having problems with this.

    Now knowing what it does, that could be quite useful. Would be great if I want to join a massive amount of lines in VI (uppercase J) over a slow connection. It’d still draw it all upon ctrl+q, but then I know I can tab away while it labors over the joins.

  6. That’s a great use of ctrl+q, Jerek! Thanks!

  7. Sri Kiran Jyothi

    This was one hell of a bugging issue. Thanks a lot for getting rid of a really big pain in the neck.

  8. Tree

    Its good to recover from ctrl-s BUT i need ctrl-s a lots in emacs, putty freezes everytime i press ctrl-s, how can i disable it?

    Strange, sometimes i have this problem, sometimes i dont. I dont get it.

    If you can help me, thanks

  9. Tree

    Ok, i figured it now.

    http://blog.i64.pl/PiosBlog/200610/29-linux-keyboard-shortcuts-you-should-know-about/

    for somereason, my emacs lost his configuration when ran under screen. i created new screen window, started emacs and ctrl-s worked as search command as it should.

    Thanks.

  10. Hey Tree, thanks for the update and the URL!

  11. Lucas

    Thanks a lot for this!!!

  12. Thanks For this, I found a way of disabling the CTRL-S sending XOFF.

    add this to your .bashrc (man stty for more options)
    stty ixany
    stty ixoff -ixon

    Some programs like rtorrent listen for CTRL-S. This might still be getting mapped to XOFF, we have only disabled listening to keybopard XOFFs NOT sending them. If you need to send CTRL-S and/or CTRL-Q you can add
    stty stop undef
    stty start undef

  13. Hey Morgy, thanks a lot for the tip! That is really useful.

  14. Blaze P.

    thanks so much saved my life!!!

  15. Thank you soooooo much! This has been really driving me crazy. Thanks!!!

  16. TF Wang

    Thank you so much! Thank you , thank you!!

  17. Thank you! This has been driving me nuts all day while I’ve been working in VI! My CTRL-S habit kept “freezing” Putty and requiring me to reconnect to the server, argh!!

  18. K

    Man, you’re my saviour !

  19. Said

    Hey, thanks for a nice tip..
    bless google + helpful people on the internet

  20. dyl

    Just had to say thanks, I should have googled this a long time ago! d’oh! I use vi for text editing but I often hit ctrl-s out of habit from the many Windows programs using that shortcut to save.

    This also sounds like a great way to hide some commands if someone is looking over your shoulder! hehe

  21. Haha yeah, it would definitely be a good way to hide commands from someone looking over your shoulder, but you’d need to have very good typing accuracy! :D

  22. Just to echo other people thanks!
    I have bitten by this quite a few times, pressing Ctrl-S by accident when I wanted to press Ctrl-A in emacs.

  23. silk

    WOOT!!! i completely agree with your “i should have googled it” … so nice!!

Reply to “Recovering from CTRL+S in Putty”