Suspending in Bash: Quickly switch between running processes in bash
This is just a quick post, but if you've ever been doing something in the terminal, for example you were editing a file (
vim somefile.txt), but you wanted to return back to the main command line, then you can do the following:
ctrl + z - this will suspend the current job (current process) - although sometimes, such as in Vim in insert mode, it won't always work. You should return to the main command line. Do whatever you want to do. Then to get back to that process type
fg (for foreground).
To see all suspended processes, use the
If you want to go back into a specific job then get it's ID (from the
jobs command), and type
fg 123, where 123 is that ID.
An alternative is to use
screen (and it is always a good idea to use screen if you are connection is a bit dodgy and you're connecting via ssh to another server, so you can pick up where you left off if your connection dies.)
If you want to start a program and push it directly into the background, then you can do
./someScriptOrProgram.sh & (add a ampersand to the end of it).