I know about "not using sudo su -" etc. But let's be honest, almost all of us do it.
So, here is the issue. We can't have root logins enabled, so we have to ssh in as our user then su to root.
Here is the process tree:
1 7897 7826 7826 ? -1 S 1000 0:00 sshd: josh@pts/0
7897 7898 7898 7898 pts/0 8182 Ss 1000 0:00 \_ -bash
7898 7990 7990 7898 pts/0 8182 S 0 0:00 \_ sudo su -
7990 7991 7990 7898 pts/0 8182 S 0 0:00 \_ su -
7991 7992 7992 7898 pts/0 8182 S 0 0:00 \_ -su
7992 8182 8182 7898 pts/0 8182 R+ 0 0:00 \_ ps axjf
I would like to exit from root, then from my user with one command. Is there a way to do this?
BTW exit && exit does not work because it exits the shell and doesnt process the rest of the command
josh@ubuntu:~$ sudo su -
root@ubuntu:~# exit && exit
logout
josh@ubuntu:~$
sudo su, it's pointless and just launches an extra process. Usesudo -i, if you have to, instead. – terdon Sep 11 '15 at 17:52sudo -ito obtain a root shell. As to ssh, you can configure ssh to allow root logins, personally I use the "without-password" options for root and either ssh keys er kerberos. This keeps the root account locked to passwords. – Panther Sep 11 '15 at 17:52exitexitssu, the second one logouts. Isn't it what you wanted to do? – Pilot6 Sep 11 '15 at 17:59exitthat anotherexit. It does the same asexit && exit. – Pilot6 Sep 11 '15 at 18:00killall --user $userwhere user is your login user – Panther Sep 11 '15 at 18:06exit && exitfails - first&&evaluates the LHS (Left Hand Side) of the expression and exits. Second, but it has already exited, and returned control to the parent. – waltinator Sep 12 '15 at 05:18exit, which is a lot quicker in my opinion. In a situation such as the one you describe I would simply hit Ctrl+D twice to exit both shells. You don't even have to let go of the Ctrl key; simply hold it down and hit D twice. Super fast. :) – Malte Skoruppa Sep 12 '15 at 11:25