Switch to parent shell without logging out

You can simulate a CTRL-Z (which you normally use to temporarily background a process) using the kill command:

[tsa20@xxx01:/home/tsa20/software]$ kill -19 $$

[1]+  Stopped                 sudo -iu tsa20
[root@xxx01 ~]# fg
sudo -iu tsa20
[tsa20@xxx01:/home/tsa20/software]$

bash just traps the CTRL-Z key combination. kill -19 sends SIGSTP to the process which is effectively the same thing.


Csh, bash, ksh, zsh, have a suspend builtin command (or alias, in ksh) that does exactly that. This command is mostly equivalent to sending a TSTP signal to the shell; bash and zsh do a bit of additional signal handler and juggling, and in these shells the suspend command works even if the shell is currently ignoring TSTP.

You can also send the signal to the shell manually with kill -STOP $$.

Tags:

Shell