I know that I can quit the terminal using the exit command when I'm running the terminal as the normal user. By normal I mean the default user that gets created when a linux distribution gets installed. But when I change from current user to root, if I try to exit the terminal, I have to execute the exit command twice. The first one to exit the root user, the second one to quit the terminal. Is there any command to quit the terminal regardless of which user is using it?

1 Answer 1


You don't mention how you change users. I'll assume sudo -- it could be something else (e.g., su).

If you want the non-root user's shell to terminate when the sudo terminates (when you type exit as root), you can do:

$ exec sudo -i

Here the exec replaces the user's shell process with the new command (here, sudo). When you type exit as root, sudo will terminate. Since the exec replaced the user's shell process with sudo, then there's no user shell to which to return.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .