To resume a process that you have moved to the background (usually by pressing Ctrl + Z), you use the "Job Control" commands. Here are the most common ways to do it:
1. The fg Command (Foreground)
This is the most common way to bring a process back. It brings the process back to the "front" so you can interact with it again.
- Command:
fg - What it does: Resumes the most recently suspended job and puts it back on your screen.
- Best for: When you were using an editor like
nanoorvim, hitCtrl + Zto check something, and now want to go back to typing in that file.
2. The bg Command (Background)
Sometimes you want a process to keep running, but you don't want it to take up your screen (for example, a long download or a script).
- Command:
bg - What it does: Resumes the process but keeps it in the background. You get your command prompt back immediately while the process continues to work.
3. Managing Multiple Jobs
If you have suspended multiple things, you need to tell Linux which one to resume:
- Type
jobs: This will show you a list of everything currently paused/backgrounded.[1] + suspended nano file1.txt [2] - suspended top - Use the ID: To resume a specific one, use
fgfollowed by%and the number:fg %1(Resumes nano)fg %2(Resumes top)
Summary of Workflow
Ctrl + Z: Pause/Suspend the current task.jobs: (Optional) Check what is currently paused.fg: Bring it back to your screen to continue working.
Try it out:
- Type
top(this shows system processes). - Press
Ctrl + Z. You will see a message like[1] + stopped top. - Type
fgand press Enter. You are now back inside thetopprogram!