Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

      -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.
share|improve this answer
Ahha! That's what I was looking for. – Brian Dec 8 '11 at 15:41

Try with:

kill -STOP $$

where $$ is the PID of the current shell.

You can bind it to Alt + z for example by adding to ~/.inputrc:

"\ez": "kill -STOP $$\n"
share|improve this answer
Excellent, thank you! Never knew about .inputrc – Brian Dec 6 '11 at 17:51
It controls the way bash reads/edit the user input, see man readline, it can be very useful, it's worth to mention the commands: history-search-backward and history-search-backward. – cYrus Dec 6 '11 at 18:08

Not exactly what you were asking for, but I normally use screen when I'm doing things like that. However, screen is not installed by default on all systems.

share|improve this answer
I actually work in screen all the time. I run screen on my local machine and have SSH sessions into a bunch of others. So I don't typically run screen on the remote systems because screen-within-screen is clumsy. And I'm too lazy to open another session :-). I'm used to hitting ^Z in vim to suspend it when I need to run some commands (I know vim has ! but it's not the same as a shell). – Brian Dec 8 '11 at 15:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.