Is there a command to close a terminal window via commandline?
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
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
There is an alternate way, which requires a bit more keystrokes, but is worth knowing.
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.
I know this answer is a little bit late but, If you are using Ubuntu or another Linux distro, simply use Ctrl+D to close the entire terminal.
I initially tried all the rest and they were just not working. For example I see people recommending
exit but honestly, it just doesnt work.
I hope someone agrees with me.
To close the terminal whilst leaving all running processes to continue running, you can do the following:
- pause the process using Ctrl + Z , pull it into the background with
bgand then disown it, eg:
+ vlc & disown
This will leave the current running process running in the background and close the terminal(i find this to be very useful).