Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

shameek@shameek-K55VD:~$ 

to

root@shameek-K55VD:~#. 

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

root@shameek-K55VD:~# 

to

shameek@shameek-K55VD:~$

and then I can close the terminal.

share|improve this question
1  
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

4 Answers 4

up vote 49 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
11  
With 1 slight cave-at: if $IGNOREEOF is active control-d is not useable. –  Rinzwind Sep 6 '13 at 5:47
4  
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
1  
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
6  
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
2  
Within the specific context of this question, OP was having trouble exiting from a root terminal... –  acolyte Sep 6 '13 at 13:43
2  
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
2  
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

 
discard

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.