Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the js_composer domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/holhol2/public_html/wp-includes/functions.php on line 6121

The Linux fg command

By holhol24 | June 6, 2021
The Linux fg command

Have you ever wondered how you can send a job or process running in the background to the foreground on the Linux shell? The fg command, short for the foreground, is a command that moves a background process on your current Linux shell to the foreground. This contrasts the bg command, short for background, that sends a process running in the foreground to the background in the current shell.

The fg command & example usages

In this guide, we will demonstrate how to use the fg command.

Basic syntax

Additionally, you can invoke one of the symbols shown below to reference a job on the current shell.

%- – This represents a previous job

%% or %+ – This shows the current job.

%number – This represents the job number, for instance, %3 or %4.

%String – A job started by a command that comprises a string, e.g., %ping

We will simulate sending a job to the background and then bringing it to the foreground using the fg command.

So, launch your terminal and execute the ping command as shown such that it continuously sends ICMP echo requests without stopping.

Then interrupt it by pressing CTRL + Z. This causes it to stop running in the foreground of the current shell and run to the background. Use the jobs command to displays all jobs that are currently suspended or running in the background.

Take note of the output. Here, the 1 is job_spec

[1]+ 2547 Stopped                 ping google.com

Now, to bring the ping command to the foreground, use the fg command as follows:

From the output, you can see that we have brought the ping command back to the foreground. You can also run the command below, which brings to the foreground the previously suspended command.

For additional information about the fg command run:

holhol24

I am a Linux server pro admin and enthusiast, an upcoming web developer, junior php developer. I am currently a content creator for Holhol24, I love to play with Linux and all other distributions of it. I loves working with computers and strongly believes in sharing knowledge. Follow me For more insight into what is happening in Tech.

Advertisement Share: Facebook Twitter WhatsApp

Deprecated: File Theme without comments.php is deprecated since version 3.0.0 with no alternative available. Please include a comments.php template in your theme. in /home/holhol2/public_html/wp-includes/functions.php on line 6121

Leave a Reply

Your email address will not be published. Required fields are marked *