So when I am logged in as a standard user in an ssh session and then su to root, how can I log out of both accounts with a single command?

Rather than:


something like:

root@host:/magicallyLogEveryoneOut -bladow
  • Possible duplicate of serverfault.com/questions/3246/… – Ramesh Mar 26 '14 at 14:57
  • Rather not a duplicate - killing the parent session does accomplish nothing. – guntbert Mar 26 '14 at 15:08
  • 2
    The fastest thing would be to press ctrl-d mutiple times until the window closes... – chaos Mar 26 '14 at 15:09
  • The CTRL-D method is the one I would recommend. – Bratchley Mar 26 '14 at 15:12
  • Didn't know about ctrl-d. So smooth. #firstworldproblems – 111--- Mar 26 '14 at 15:15

Seeing that any command you type takes more keystrokes I recommend CTRL D , CTRLD, which takes you out of both sessions.


For your exact question about doing this in one command: on one of my RHEL boxes this command works:

fuser -k `tty`

Which SIGKILL's (aka -9) any PID attached to the terminal. Your system's getty program should respawn on its own. I just tried it and it kicked me out of a session where I had sudo'd to root.

I'd be hesitant to do this though, since I run a lot of background jobs and I'd be paranoid that I'd leave one of them running. Also, this is pretty lazy (no offense).

I'd suggest you just have a habit of doing a CTRL-C followed by a bunch of CTRL-D' until the window closes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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