How to suspend bash within bash

bashkeyboard shortcutsprocessshell

Is it possible to suspend a bash that was invoked by another bash? For example, if I use su to become a different user but want to switch back to my own user for a moment. For another example, in an SSH session, I can use the ~ shortcut (~, ^Z) to suspend the remote shell and return to my local shell (but that's obviously an SSH feature, not the shell).

bash intercepts ^Z to do its own process control, so it must be a separate command (if it's even supported). But trying to find it only results in information about the normal process control.

Best Answer

Bash has a suspend builtin:

suspend: suspend [-f]
    Suspend shell execution.

    Suspend the execution of this shell until it receives a SIGCONT signal.
    Unless forced, login shells cannot be suspended.

    Options:
      -f    force the suspend, even if the shell is a login shell

    Exit Status:
    Returns success unless job control is not enabled or an error occurs.
Related Question