How to resume a background process?

QuestionsQuestions8 SkillsProDec, 20 2025
0211

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 nano or vim, hit Ctrl + Z to 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:

  1. Type jobs: This will show you a list of everything currently paused/backgrounded.
    [1]  + suspended  nano file1.txt
    [2]  - suspended  top
  2. Use the ID: To resume a specific one, use fg followed by % and the number:
    • fg %1 (Resumes nano)
    • fg %2 (Resumes top)

Summary of Workflow

  1. Ctrl + Z: Pause/Suspend the current task.
  2. jobs: (Optional) Check what is currently paused.
  3. fg: Bring it back to your screen to continue working.

Try it out:

  1. Type top (this shows system processes).
  2. Press Ctrl + Z. You will see a message like [1] + stopped top.
  3. Type fg and press Enter. You are now back inside the top program!

0 Comments

no data
Be the first to share your comment!