Terminal frozen after Ctrl+S: XON/XOFF flow control and Ctrl+Q
Ctrl+S tells the host's terminal driver to stop output, so the screen looks frozen. Press Ctrl+Q to resume, or turn it off with stty -ixon.
If a remote shell or editor suddenly stops showing what you type, and you had just pressed Ctrl+S (often by habit, to save), the session is probably not hung. Output has been paused.
Press Ctrl+Q. Everything you typed while it was paused appears at once.
Why Ctrl+S stops the screen
On Unix and Linux hosts, the terminal driver on the host side has XON/XOFF flow control. It dates from serial terminals that needed a way to tell the computer to wait. When the ixon setting is on, two control characters are handled by the driver itself and never reach the program:
- Ctrl+S (the
stopcharacter, XOFF) stops output. - Ctrl+Q (the
startcharacter, XON) restarts it.
Your keystrokes still arrive while output is stopped, so a command you typed blind may run when you press Ctrl+Q. Check the screen before pressing Enter again.
See what is set with stty -a. A typical Linux host shows start = ^Q; stop = ^S and ixon (no minus sign) in the input settings.
Turn it off
To make Ctrl+S reach programs instead, turn off XON/XOFF flow control:
stty -ixon
This lasts for the current login. To keep it, add the line to ~/.bashrc (or your shell's startup file) so that it runs only in interactive shells, where there is a terminal. A non-interactive shell has no terminal, and stty would print an error there.
To switch it back on: stty ixon.
Programs that want Ctrl+S
- Bash binds Ctrl+S to
forward-search-history, the forward partner of Ctrl+R. Withixonon, the driver takes the key first, so Ctrl+S freezes the screen instead of searching. - Editors and other full-screen programs may bind Ctrl+S to save or search. A program that puts the terminal in raw mode gets the key, because stty's
rawsetting includes-ixon. A program that leavesixonon never sees Ctrl+S.
On a 5250 or 3270 screen
This is a VT (Unix and Linux) behavior. On an IBM i 5250 screen or a z/OS 3270 screen, keys are handled by the emulator and the host's display station rules, not by a Unix terminal driver. If you connect to IBM i in VT100 mode, IBM says not to map 5250 functions to Ctrl+S and Ctrl+Q when the client uses flow control: see IBM i VT100 key map: F1–F24, Field Exit, Error Reset, SysReq.
Related
- Keys and key codes
- Ctrl+C copies instead of interrupting, or Ctrl+V and Ctrl+A never reach the host
- Fix a terminal full of garbage after printing a binary file
- Shell and tmux basics
- App guide: Keyboard shortcuts