Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
2  
Ideas: open a new terminal or terminal tab; use screen and create a new screen; use pushd and popd, or cd - –  glenn jackman Mar 26 at 18:08

3 Answers 3

up vote 2 down vote accepted

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

share|improve this answer
    
suspend & fg & bg will do, but they don't support interactive or ncurses-like processes. –  0xSheepdog Mar 26 at 19:04
1  
@0xSheepdog, you can suspend an interactive ncurses based program just fine. –  psusi Mar 26 at 19:49

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. Of 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, ..).
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

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.