1
00:00:01,200 --> 00:00:04,410
Hello, everyone, and welcome to this lesson.

2
00:00:04,830 --> 00:00:12,000
So in this video, we're going to see how you can start a process in the background.

3
00:00:12,030 --> 00:00:15,840
Bring it to the foreground and how you can kill that process.

4
00:00:16,230 --> 00:00:17,000
Perfect.

5
00:00:17,010 --> 00:00:18,660
So let's quickly begin.

6
00:00:19,200 --> 00:00:25,770
So to start a process in the background, we are going to add ampersand sign at the end.

7
00:00:25,800 --> 00:00:27,210
As you can see over here.

8
00:00:27,360 --> 00:00:34,980
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

9
00:00:34,980 --> 00:00:37,590
at the end of the command.

10
00:00:37,800 --> 00:00:39,420
And you can see a new process.

11
00:00:39,420 --> 00:00:48,270
ID has been assigned to this which is two five, eight four and you cannot see the nano screen over

12
00:00:48,270 --> 00:00:52,620
here because it is automatically pushed in to the background.

13
00:00:52,920 --> 00:00:53,640
Perfect.

14
00:00:53,880 --> 00:00:58,080
So now we have our PID, which is 2584.

15
00:00:58,110 --> 00:01:02,520
Let's verify that using OCS and let's grep for nano.

16
00:01:02,580 --> 00:01:08,850
And you can see there is a process which has been running which is 2584 PID.

17
00:01:08,880 --> 00:01:09,300
Perfect.

18
00:01:09,330 --> 00:01:13,590
Now, as we know, this process has been pushed to the background.

19
00:01:13,590 --> 00:01:20,340
So let's verify that using the command BG and you can see the process is running in the background and

20
00:01:20,340 --> 00:01:22,110
the command is nano, x, y, z.

21
00:01:22,500 --> 00:01:28,860
In case you want to bring this process to foreground, we are going to use the command f g and you can

22
00:01:28,860 --> 00:01:32,190
see the nano terminal through which you can add it.

23
00:01:32,370 --> 00:01:38,700
Now this is very handy sometimes in case you want to spawn a process, push it automatically into the

24
00:01:38,700 --> 00:01:45,510
background, and at a later point of time you want to resume the process or resume your work and start

25
00:01:45,510 --> 00:01:46,380
editing it.

26
00:01:46,890 --> 00:01:49,680
Now this becomes very, very useful and handy.

27
00:01:50,220 --> 00:01:52,470
Now let's go back over here.

28
00:01:52,470 --> 00:01:58,260
And if you want to kill the process that has been running, you do not need it anymore.

29
00:01:58,290 --> 00:02:00,540
So let's kill the nano process.

30
00:02:00,540 --> 00:02:05,690
So kill and the PID of the current process that has been running and hit enter.

31
00:02:05,700 --> 00:02:09,150
And you can see we have successfully killed the process.

32
00:02:10,260 --> 00:02:11,640
So this is it for this video.

33
00:02:11,670 --> 00:02:19,380
I hope you guys understood how you can push a process in a background, how you can bring it to foreground

34
00:02:19,380 --> 00:02:22,830
and how you can kill it if you no longer need it.

35
00:02:23,370 --> 00:02:24,000
Thank you.
