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?
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.