4

Say you're in a directory and you want to check something in another directory, so you type bash to spawn a new shell so you can cd and check that thing and then type exit to get out and go back to the original shell still in that old directory.

Is there any way to keep both bashes running and switch between the two, sort of like Ctrl+Z + fg/bg?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
user63658
  • 101

3 Answers3

4

There are several ways to do this:

  1. If you are behind the physical console, just switch to a different TTY.
  2. If you are not behind the console and you are using a graphical interface, just start a new xterm.
  3. If you are SSH-d in or do not like either of the first two, you can:
    • Start screen (old, spaghetti code, but well tested).
    • Start TMUX (A modern screen-like replacement)
    • If the original program does not need input, suspend it (e.g. Controlz) and then tell it to continue running in the background (bg). If you wish you can switch between tasks by suspending the current one and bringing the desired task to the foreground (fg). E.g. use jobs and fg %1, fg %2, ...).
Hennes
  • 2,038
3

You can use the suspend command to background the child shell and return to the parent shell.

psusi
  • 17,303
0

Yes, the app/command you should look into is screen. It will let you detach a shell session which continues to execute on its own.

http://www.howtoforge.com/linux_screen

0xSheepdog
  • 2,750