Which combination of keys is used to exit from terminal

Which combination of keys is used to exit from terminal?

Ctrl + t
Ctrl + z
Ctrl + d
Ctrl + e
See more at: http://technicalworldforyou.blogspot.in/2013/06/basic-linux-mcq-questions-for-beginners.html

The Correct Answer and Explanation is:

The correct answer is: Ctrl + d


Explanation

In a Linux or Unix-based system, the terminal is a command-line interface used to interact with the operating system. One common task is exiting the terminal session or logging out from a shell, especially when working in a command-line environment.

The key combination Ctrl + d is used to exit the terminal. Specifically, it sends an EOF (End Of File) signal to the shell. If the shell is expecting input and receives EOF instead, it understands that there is no more data to read and terminates the session.

Why Ctrl + d Works:

When you use a command-line shell (like bash, sh, or zsh), it typically reads user input line by line. When Ctrl + d is pressed at the beginning of a new line, it tells the shell there’s no more input (i.e., end-of-file). If you’re not running a process that expects input, the shell interprets this as your intention to end the session.

This method is commonly used when:

  • Logging out from a user session in a terminal.
  • Exiting a python, mysql, or other REPL environments.
  • Finishing input redirection from a terminal (like input to cat or mail).

Other Key Combinations (for comparison):

  • Ctrl + t: Often used in text editors or browsers to open a new tab (not relevant for exiting the terminal).
  • Ctrl + z: Suspends the current process and returns control to the shell. The process can be resumed later using fg or bg.
  • Ctrl + e: Moves the cursor to the end of the line in bash or other readline-based interfaces.

Therefore, the most appropriate key combination to exit a terminal session is Ctrl + d.

Reference: Basic Linux commands and shell behavior.

Scroll to Top