Hello again, and now in this lesson, we are going to cover process management, what is a process
management, anything that has to do with the process, how we manage it, how we started, how we stop
it, and how we bring it in the foreground, how we bring it in the background.
All that stuff is process management.
Let's go over.
All the commands are associated with the managing processes.
The first one or the set of commands that we have are putting a process in the background.
So why do we need to put a process in the background?
Let's talk about that first.
Then you run a process on your terminal, meaning when you open up a console or when you open up a PUDI
terminal, then you run a process on your terminal.
It will run it and it will not give you your prompt back.
So if you want to do certain other tasks or you want to exit out of it, it will stop your process.
So how do you run in the background?
So the command is control zephyrs.
You run the run the process and tight controls, it will stop the process.
Then you type jobs to list what is being stopped and then you Tiberg, which is to put the process in
the background, then we have foregrounded.
So if you are done with all other tasks that you are doing on your terminal and you want to bring the
process that you had put in the background initially and you wanted to see the process of it, then
you type EFG football ground and that process will become live again on your console to run a process
even after you exit.
Meaning if you exit or if you close your terminal while your process is running, what will happen?
It will stop the process.
So how do you prevent it?
There's a command called No Hop.
It means don't send any kind of signal to stop it.
So no hop the process and followed by the sign ampersand or and sign, which is on top of your No.7
key on your keyboard and another command for that as no hub the process and redirects sign to dev null
and to redirect ampersand one and ampersand again.
Why do we have all that stuff there.
Because certain times when you run certain commands like no, it gives some kind of warning, some kind
of information about that process.
So you don't want to see that.
You want all that garbage to set to go out to Dev null.
So Domhnall is kind of outplaying to a door that you don't want to see the output for then to kill a
process by name.
You you guys already know how to kill a process by process idea.
Right.
So you kill pahlevi the process, it kills the process.
What if you want to kill a process by its name.
So let's say if you have a command, if you have a process called top.
Right, so you, you run the command top, you kill if you wanna kill it by the name, you just simply
type kill, followed by the the name of the process which is top process priority.
Nice.
There is a command call.
Nice.
And why do we use it.
Because if he wanted to privatize by different level of process, meaning if a process is very important
then the other it has to be prioritized.
Right.
So the niceness scale goes from minus 20 to 19.
The lower the number, the more priority that task gets.
Now, why do we really need to go with the priority of the task?
Doesn't that processor CPU takes care of that?
Right.
It does take care of it.
But remember one thing.
If you have one CPU in your computer or your laptop, it means it will process one program at a time.
So think of it as a juggling.
So if you have two hands and you have five balls to throw it in the year, what will happen?
Can you hold all five of five balls that you had?
No right.
So think of balls as programs that you need to process, so you would have to juggle it one after you
the other.
So what Nice does is nice tells, hey, this ball or this process is important to me.
So make sure this stays in the hand most often than any of the balls.
So that's what Nice does.
We'll talk about that when we open up our terminal session.
Then how to monitor a process is by running the command top and how to list all the processes that you
have running in your computer.
The command is followed by, of course, many different options that you use.
So anyway, let's get into our Linux machine.
I have it open right here.
Console.
So I am logged in as myself, I want to become root, so the root now I wanted to log in to the police
station as well as this way I could run certain different programs, one terminal and kill it on the
other terminal.
So for that to log into the PUDI, what do I need?
I need an IP address on my machine.
The command is IP Hadeed or if config, whichever you prefer.
But if you are running a latest version of Linux, then you probably not going to have config.
So run IP command and IP address.
You'll see right here.
It says 100 to 168, 56, one, two, one.
So go into your PUDI terminal.
I have my PUDI terminal right here and I'm going to type it in my IP address, which is one eight to
one sixty eight fifty six point one one hit enter login as wrote.
The first one is Control Z, so I'm going to run a command called Sleep.
Sleep is a command which will delay certain programs.
Let's say if you're running a program, ABC and you wanted to run a second set of program, but you
wanted to wait for ten seconds, so you put it asleep command.
That's what it does.
It just waits for ten seconds and it goes to the next set of instructions.
So if I type let's say if I type the five, it will wait for five seconds until I got my prompt back.
You'll see.
I'll get them up.
I got the problem back, by the way, after five seconds.
So that's what it does.
Don't focus too much on speed.
Focus on what I'm going to teach you about process management.
So I'm going to leverage this lesson on the command sleep.
So this will be easier to understand.
So if I run the command sleep 100, what will happen?
I will have to wait 100 seconds until I get my job back.
Right.
So I want to run that process in the background so I will do control Z.
It has stopped the process.
Now, it's not running actually in the background.
To run that in the background, you have to type the command B.G., which is for background.
But let's say if you if you are running multiple process and they are all of them stopped, some of
them are running to the command to check what is what are the process that are stopped right now.
So you just type commands jobs and you will see there is one process that's been stopped by the command
control.
See if you want to run the process, bring it and send it to the background.
Then you type B G.
This will send this process in the background.
You see it is running now.
So when you type jobs, you'll see right here it's not stock C, it's running so but it is running in
the background.
You could also check by my command by typing sleep and you will see right here sleep 100, the other
sleep 60.
You could ignore that.
This one's all the time.
If you are running, watch the machine anyway.
Sleep one one is still running.
What if you want to bring it in the foreground then you type f, g, c.
It's brought back the process in the foreground and now you notice I do not have my problem back.
Why?
Because it the process is still running.
So what if I wanted to put it back in the background.
You OK.
So hundred seconds are done.
I got my back.
If I wanted to put it back in the background I would have type control zek.
OK, so now this next one we have is about no process.
What is a no up.
Well no hub is if you run a process and then you close your terminal meaning this terminal.
If I close it right now let's say if I'm running a command sleep one hundred it is going to run or it's
going to wait for hundred.
If I go to my console it clear the screen and I type minus G.F. and do grep sleep.
You'll see the sleep 100 is running.
Right.
So if I wanted to
knock this terminal that's closest to a couple of terminal open.
So if I close this and then do massive sleeps now you will see both sleep 100 are gone.
So every time you run a process, it attaches itself to that terminal.
Now how do we run a process without interrupting the process when we close a terminal?
So let's go to our position again to run a process in the background and that.
And when you closed the terminal.
It won't impact it, you run club.
And the name of the process, which is Sleep 100,
that's put to sleep 75 is to differentiate it and ampersands.
So you hit enter and you will see now it's running that process in the background.
So when you do jobs and you'll see it is running, but it is not impacting your terminal, it's not
attached to your terminal.
So even at this time, if you close it, this process will still run.
Now, what about this?
No hub ignore input and a pending output to no hub out.
Well, every time you run a no hopped up, no hop command, it actually creates a file called no hub
dot out.
So what it has, it has all the information, all the things that you have typed in there.
It will just record everything.
But if you just don't want to see that message comes up on the screen are many times when you run certain
commands, it gives you a message that this command was created in this day and so many other stuff.
So to get rid of that message, you could type no hub sleep.
Seventy three is to differentiate again.
Go ahead and sign stash Duff's national to go ahead and sign and percent one and percent again hit enter
and now you will see you did not get all that stuff that you weren't getting it before.
Because what we are saying is whatever that comes up on the screen, those error messages warning or
those even informational messages to send it to Dev null, don't send it on the screen, so send it
in the back.
Now, what if you want to see what's running in the back?
We were on jobs and you'll see this one.
A process is running in the back in the background.
Now, again, what if you want to bring that process in the forefront, in the foreground, just type
foreground and you will see it is running and it is on the foreground and you will not get your prob
back until it waits for 73 seconds.
Once it's finished 73 seconds, then we'll get up Krombach anyway.
Let's control Serov it, which will completely stop because if you type jobs now you won't see any jobs.
The next lesson or sorry, the next topic of this lesson is about process party, which means run a
process with a certain priority.
So you could just simply type nice space minus N and space.
What's the priority?
You want to give it minus 20, which is the highest one?
No, I don't want to mess up my other processes in the system.
So I'll just say simply say five and then I'll do sleep minus ten.
I had error.
Now what it's doing is it's telling C.P.U, hey C.P.U, I have this process.
Sleep ten and please give this process priority five, which is not too high, which is not too low.
It will tell that to the CPU and CPU will process that according to the command of Nice.
That's what NICE's.
If you want to run your process to be the top priority, it is very important then I would say run nice
minus and minus 20.
The name of the process had error and CP will say, hey, that said, I have nothing to do but to take
care of this process right away.
That's about the nice are the priority.
The other ones we already covered, which is a process monitoring and of course the list of process
to see what the process are available and the system.