sodcalculator

10 Tech How-To

Fix Can’t Type in Terminal on Linux

Guide 10-45586 · Updated · Step by step

If your Linux terminal stops accepting keyboard input, the fix is usually to reset the terminal state with the reset command or by restarting the terminal emulator. This issue often happens after a program crashes, a command hangs, or you accidentally press a key combination that freezes input. Below are the most reliable ways to restore typing, along with the reasons it happens and how to prevent it.

Why the Terminal Stops Accepting Input

The terminal on Linux is not just a window that displays text—it is a full-screen application that communicates with the kernel through a pseudo-terminal (pty). When you type, the terminal driver processes each keystroke and sends it to the foreground process. Several things can break this chain:

  • Terminal freeze (Ctrl+S): Pressing Ctrl+S sends a pause signal (XOFF) that stops all output and input until you press Ctrl+Q (XON). This is the most common cause and is easy to fix.
  • A crashed or hung program: If a program like vim, less, or a Python script crashes without restoring the terminal’s original settings, the terminal can be left in a raw mode where keystrokes are not echoed and the Enter key does not work normally.
  • Stray escape sequences: Running a command that outputs binary data or special control characters can confuse the terminal emulator, making it appear that typing has no effect.
  • Keyboard or window manager issues: Sometimes the problem is not the terminal itself but the window manager grabbing keyboard shortcuts, or a stuck modifier key (like Ctrl or Alt) that makes the terminal receive different input.

Quick Fixes to Try First

Before doing anything drastic, try these in order. They are safe and take only seconds.

  1. Press Ctrl+Q: This un-pauses the terminal if you accidentally pressed Ctrl+S. It sends the XON signal and usually restores typing immediately.
  2. Press Enter a few times: If a program is waiting for input, pressing Enter can wake it up. If you see a new prompt appear, typing should work again.
  3. Press Ctrl+C: This sends an interrupt signal to the foreground process. If a program is stuck in an infinite loop or waiting for something, this will terminate it and return you to the shell prompt.
  4. Type reset and press Enter: Even if the terminal looks unresponsive, typing reset (you may not see the characters) and pressing Enter will run the reset command, which reinitializes the terminal settings. This works in most cases.
  5. Close and reopen the terminal window: If the above fail, simply closing the terminal (using the window manager’s close button or Alt+F4) and opening a new one will give you a fresh shell. This is a guaranteed fix because it creates a new pty.

How to Reset the Terminal from Another Terminal

If the terminal is completely frozen and you cannot type anything, you can open a second terminal window and reset the first one. You need to know the process ID (PID) of the shell running in the frozen terminal.

  1. Open a new terminal window.
  2. Run ps -t pts/0 (replace pts/0 with the correct pseudo-terminal name, which you can find by running tty in the frozen terminal—but if you cannot type, look at the title bar or use who to see which terminal sessions are active).
  3. Find the PID of the shell (usually bash or zsh).
  4. Run kill -9 PID to force-kill the shell. The terminal emulator will then close or show a message that the process ended.
  5. Alternatively, you can run reset from the second terminal with the correct tty: reset < /dev/pts/0. This sends the reset command to the frozen terminal’s input.

This method is useful when the terminal is so unresponsive that even Ctrl+C does not work.

Preventing the Problem

Most causes of a non-typing terminal are avoidable with a few habits:

  • Use Ctrl+S only when you intend to freeze output. Some users accidentally press it when reaching for Ctrl+D (logout) or Ctrl+X. If you do not use the XOFF feature, you can disable it by running stty -ixon in your shell configuration file (e.g., ~/.bashrc). This makes Ctrl+S do nothing, so it cannot freeze the terminal.
  • Always exit programs properly. Use exit or the program’s quit command (e.g., :q in vim) instead of killing the terminal window. This ensures the terminal settings are restored.
  • Avoid running binary files or cat on binary data. If you accidentally do, press Ctrl+C immediately and run reset.
  • Check for stuck keys. If you are using a laptop, a stuck Ctrl key can cause all sorts of weird input behavior. Test with another keyboard or use the on-screen keyboard to see if the issue persists.

Common Misconception: It’s a Keyboard Problem

Many users assume the keyboard is broken when the terminal stops accepting input. However, the keyboard is usually fine—the terminal emulator is simply not receiving or processing the keystrokes correctly. You can verify this by opening a text editor or another application; if typing works there, the issue is isolated to the terminal. Another misconception is that you need to reboot the computer. In most cases, a reboot is unnecessary; the fixes above resolve the issue without losing your session.

When the Terminal Emulator Itself Is the Problem

If the issue happens across multiple terminal windows or after every command, the problem may be with the terminal emulator application (like GNOME Terminal, Konsole, or Terminator) rather than the shell. Try the following:

  • Restart the terminal emulator: Close all windows of that emulator and reopen it. This resets its internal state.
  • Check for a stuck modifier key: Some terminal emulators have shortcuts that involve Ctrl or Alt. If a key is physically stuck, the emulator may interpret every keystroke as a shortcut. Try pressing and releasing each modifier key individually.
  • Try a different terminal emulator: If you have another one installed (e.g., xterm or tmux), open it and see if typing works. This helps isolate whether the problem is the emulator or the system.
  • Check for runaway background processes: Sometimes a background process (like a yes command) floods the terminal with output, making it appear unresponsive. Run ps aux | grep yes in another terminal and kill any such processes.

Frequently Asked Questions

Why does Ctrl+S freeze my terminal?

Ctrl+S sends the XOFF control character, which pauses output and input in the terminal. It is a legacy feature from the days of slow serial terminals. To resume, press Ctrl+Q (XON). If you never use this feature, you can disable it with stty -ixon.

What if the terminal still won’t type after pressing Ctrl+Q?

If Ctrl+Q does not work, the terminal may be in a raw mode from a crashed program. Type reset (even if you don’t see it) and press Enter. If that fails, close the terminal window and open a new one. If the problem persists across all terminals, reboot the system or restart the display manager.

Can I prevent a program from messing up my terminal?

Yes, use a terminal multiplexer like tmux or screen. These tools keep the terminal session separate from the shell, so even if a program crashes, you can detach and reattach to a clean session. They also allow you to scroll back and split windows.

Is there a difference between reset and stty sane?

Yes. reset is a program that reinitializes the terminal to its default settings, including clearing the screen and resetting colors. stty sane is a command that sets the terminal driver to a sane state, but it does not clear the screen or reset the terminal emulator. In most cases, reset is more thorough.

Why does my terminal not echo what I type?

This usually happens when a program has turned off echo mode. Run stty echo to re-enable it, or use reset. If you are in a full-screen program like vim, exit it properly to restore echo.

Can a virus cause my terminal to stop accepting input?

While it is theoretically possible for malware to interfere with terminal input, it is extremely rare on Linux. The most common causes are user error (like Ctrl+S), a crashed program, or a terminal emulator bug. Always ensure your system is up to date and only install software from trusted repositories.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →