WebMasterCampus
WEB DEVELOPER Resources

Linux fg Command

Learn Linux fg Command with examples


Linux fg Command

In Linux, we can use “fg” command continues a stopped job by running it in the foreground.

fg Command Syntax

>> fg [ %job_id ]
  • %job_id - Specifies the job that you want to run in the foreground.

What are job number (%job_id)

There are a various ways to refer to a job in the shell. The character % introduces a job specification. The JobID can be a process ID (PID) number, or you can use one of the following symbol combinations:

Command Description
%Number Use the job number such as %1 or %2.
%String Use the string whose name begins with suspended command such as %commandNameHere or %ping.
%+ OR %% Refers to the current job.
%- Refers to the previous job.

Find job Id

>> jobs -l

[1]+   160 Running                 sleep 100 &

[1] shows that job id is 1.

fg Command Example

>> fg

Typing fg will resume the most recently suspended or backgrounded job.

fg 1 Command Example

>> fg 1

Brings the job with the id 1 into the foreground, resuming it if it was suspended.

Created with love and passion.