1

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:

root@host:/exit
user@host:/exit

something like:

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

2 Answers 2

3

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

0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.