REW

What Does Ctrl G Do In Linux?

Published Aug 29, 2025 4 min read
On this page

In Linux, the function of Ctrl+G varies significantly depending on the application and context. While its most fundamental meaning is to send the ASCII bell character (BEL), its practical use is most common in shells like Bash and Zsh, where it is used to exit the history search mode. In text editors and development environments, it often serves a navigation purpose, like jumping to a specific line.

The core function: The BELL character (BEL)

At the most basic level, pressing Ctrl+G sends a control character to the terminal with the ASCII value of 7. This character is called BELL (BEL) or \a in C-style programming languages. Its historical purpose dates back to the days of teletype machines, where it would literally ring a physical bell to alert an operator.

In modern terminal emulators, receiving the BEL character typically triggers a visual or audible "bell":

  • Audible beep: The terminal emits a sound.
  • Visual flash: The terminal window or border flashes briefly.
  • Desktop environment notification: Some desktop environments integrate the bell, causing a notification to appear or a system sound to play.

You can test this yourself by running printf '\a' in your terminal.

Behavior in the command-line interface (CLI)

In the standard Bash and Zsh shells, Ctrl+G is a crucial part of the shell's line-editing capabilities.

Exiting history search

This is one of the most common and important uses of Ctrl+G in a Linux terminal.

  • When you press Ctrl+R, you enter reverse-i-search mode to find a previous command.
  • After finding the command you need, you can exit the search mode without executing it by pressing Ctrl+G. This drops the found command onto the current command line, where you can edit it further.

Standard readline behavior

Shells that use the GNU Readline library, such as Bash, have a set of Emacs-style keybindings by default. Within this system, Ctrl+G is bound to the abort command, which cancels the current operation and "rings the bell". This means if you are in the middle of a command or a partial one, pressing Ctrl+G can abort it.

Behavior in popular Linux applications

Outside of the shell, Ctrl+G behaves differently depending on the specific application. The following are common examples.

Vim

  • Normal Mode (Ctrl-G): Prints status information about the current file, such as the file name, line number, and percentage through the file.
  • Incremental Search (Ctrl-G and Ctrl-T): When performing an incremental search (where results update as you type), pressing Ctrl-G navigates to the next matching result, while Ctrl-T goes to the previous result.

Emacs

  • Cancel Command (C-g): In Emacs, Ctrl+G is the universal "cancel" or "quit" command. It aborts the current command, keystroke sequence, or long-running process. If you've typed a multi-key command prefix but change your mind, C-g will stop it. Pressing it repeatedly can serve as an emergency escape.

Text editors and IDEs

  • "Go To Line" Function: In many graphical text editors, like Gedit, as well as programming IDEs, Ctrl+G opens a "Go to Line" dialog box. You can type a line number and press Enter to jump directly to that line.
  • Visual Studio Code: In VS Code, Ctrl+G is used to navigate to a specific line or column.

The historical and cultural significance

The evolution of Ctrl+G from a physical bell to a context-sensitive command highlights the layered history of Linux and Unix systems. The ASCII bell character, a relic of early computing, remains the lowest-level function. However, over decades, application developers and shell designers have repurposed this key combination for more sophisticated, context-aware actions.

This adaptability is a hallmark of Linux. The keybinding isn't hardcoded to a single behavior but is defined by the software that receives the input. This is why a command in one environment (the shell) might perform a completely different action than in a text editor like Vim or Emacs, where its behavior is customized for that application's specific tasks.

Enjoyed this article? Share it with a friend.