Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a command to close a terminal window via commandline?

share|improve this question
up vote 30 down vote accepted

To close a terminal window you can use the exit command . Alternatively you can use the shortcut ctrl+shift+w to close a terminal tab and ctrl+shift+q to close the entire terminal including all tabs.

share|improve this answer

You can use the ^D shortcut - that is, hitting Control and d. This works in many shells and shell-like environments. Technically speaking, this key combination emits the end-of-transmission character (ASCII code 04). In gnome-terminal, i.e. bash and other shells, this is interpreted as finishing the interactive session. You can also see this behavior in programs like cat which read from standard input (the keyboard). Try running it without arguments; you can terminate by entering ^D.

share|improve this answer

is the command you want to use for that.

share|improve this answer

There is an alternate way, which requires a bit more keystrokes, but is worth knowing.

Using exec command

  • Syntax
exec <command-name>
  • This will first execute the <command-name> and then exit the shell.

  • For example, you could do:

exec sleep 1

          which would, effectively, close the window after 1 second.

share|improve this answer
It doesn't quite "exit" the shell, but it rather replaces the shell's process with the <command-name>. When command terminates, process exits. – Serg Nov 30 '15 at 11:46

Yes there is.First type echo $$ in terminal to know it's process id. Then type kill -9 processid.

share|improve this answer

Yes. The command is exit. Type exit into the terminal and press enter

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.