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

I entered sudo -s command in terminal, and the it changed from




Now when I click on the close terminal window icon it says, "There is still a process running in the terminal, closing it may kill it".

Close this terminal? dialog box

I am entirely new to Ubuntu, please suggest a command to get back from




and then I can close the terminal.

share|improve this question
If you are sure that you've finished whatever you was doing in terminal, just close by killing the [possible] process... – Gediminas Jeremiah Gudelis Sep 6 '13 at 6:06
By using "exit" or Ctrl-D, you will be warned if there are any background processes which need a terminal. Forcibly closing the terminal may cause work to be lost otherwise. – wallyk Sep 6 '13 at 21:57
up vote 57 down vote accepted

Press Ctrl+D will log you out of Super User and return you to normal user status. Alternatively, you can type exit

share|improve this answer
With 1 slight cave-at: if $IGNOREEOF is active control-d is not useable. – Rinzwind Sep 6 '13 at 5:47
To add an explanation of what is happening: sudo -s really just starts a new shell as the root user as a subprocess, rather than changing the credentials of the existing shell. To the Terminal, this is indistinguishable from any other command that is still running. You exit the inner shell just as you would exit any other. This also means that shells are stackable -- you can just invoke bash and get a new shell inside the old one. – Simon Richter Sep 6 '13 at 17:47
Also, if you haven't reset it, the SHLVL environment variable will tell you how many layers of shell you have running. – Aesin Sep 7 '13 at 11:58

Type exit then you will log off to normal user. Then type exit again to close the terminal or just close it with the mouse.

GNOME Terminal showing exit command to escape from a subshell

share|improve this answer
@EliahKagan what exactly is the difference between sudo su and sudo -s? – acolyte Sep 6 '13 at 13:33
sudo -s will not run shell environment which is specified in passwd file. But it will not change some environment variables ex: $HOME – dedunumax Sep 6 '13 at 14:28

If you're not doing anything important in the terminal, you can actually just click Close Terminal on the Close this terminal? ("Closing the terminal will kill it") dialog box.

This will send SIGHUP to the running shell, which will then quit, just like it would if you used the exit command or Ctrl+D (also good ways).

share|improve this answer

One more alternative, for stuck processes that don't want to die, is 'kill -9 -1'. Be aware that this kills whatever process the current user owns and it causes a disaster if that is 'root'. Yet another alternative is to see what you have with 'ps ux' to check what you still have running and kill it (possibly with the -9 option).

share|improve this answer
These don't seem like reasonable substitutes for exit. After all, this question is specifically about how to get out of a subshell. This is not a general "Close this terminal?" question. – Eliah Kagan Sep 6 '13 at 10:50
Within the specific context of this question, OP was having trouble exiting from a root terminal... – acolyte Sep 6 '13 at 13:43
I agree, this isn't an appropriate solution for the question. This is something you would only recommend if you've already tried to "exit" but it's not working for some reason. – Nate C-K Sep 6 '13 at 14:58
As the OP was speaking specifically from the perspective of being 'root' suggesting something that is disastrous in 'root' seems very irresponsible - to expand on what acolyte has said. – Tony Martin Sep 11 '13 at 1:38

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.