Hello, everyone, and welcome to this lesson.
So in this video, we're going to see how you can start a process in the background.
Bring it to the foreground and how you can kill that process.
Perfect.
So let's quickly begin.
So to start a process in the background, we are going to add ampersand sign at the end.
As you can see over here.
So I'm going to start a process which is nano and I want to edit a file which is X, Y, Z and ad end
at the end of the command.
And you can see a new process.
ID has been assigned to this which is two five, eight four and you cannot see the nano screen over
here because it is automatically pushed in to the background.
Perfect.
So now we have our PID, which is 2584.
Let's verify that using OCS and let's grep for nano.
And you can see there is a process which has been running which is 2584 PID.
Perfect.
Now, as we know, this process has been pushed to the background.
So let's verify that using the command BG and you can see the process is running in the background and
the command is nano, x, y, z.
In case you want to bring this process to foreground, we are going to use the command f g and you can
see the nano terminal through which you can add it.
Now this is very handy sometimes in case you want to spawn a process, push it automatically into the
background, and at a later point of time you want to resume the process or resume your work and start
editing it.
Now this becomes very, very useful and handy.
Now let's go back over here.
And if you want to kill the process that has been running, you do not need it anymore.
So let's kill the nano process.
So kill and the PID of the current process that has been running and hit enter.
And you can see we have successfully killed the process.
So this is it for this video.
I hope you guys understood how you can push a process in a background, how you can bring it to foreground
and how you can kill it if you no longer need it.
Thank you.