Modern operating systems are usually multitasking, meaning that they create the illusion of doing more
than one thing at once by rapidly switching from one execution to another.
So the kernel manages this truth, the use of the processes.
So the processes are how Linux organizes the different programs waiting for their turn at the CPU.
So sometimes a computer will become sluggish on our application will stop responding.
In this section you will learn and we will look at some of the tools available at the command line that
lets us examine what programs are doing and how to terminate processes that are misbehaving.
In this section, you will learn about command, top command, and you will also learn about the jobs.
BG which, uh, the jobs here will list active jobs.
BG Place a job in the background.
EFG.
A place, a job.
In the foreground and kill.
With this kill command, you will send a signal to a process and kill all here.
Kill all the you will send.
Kill the process by name and shut down.
Shut down.
Here you will shut down your computer.
Actually, I don't want to shut down right now.
So let's see what happens when I talk.
So actually, let's learn about how a process works.
So when a system starts up, the kernel initiates a few of its own activities as processes and launches
a program called Init in turn runs a series of shell scripts located in here and are called the init
scripts.
Actually, let's terminate the shutdown process right now with C and as you can see, we terminate the
shutdown process, clear the console and let's CD to ATC here, LZ and these are our shell scripts and
some of these scripts called Init Scripts, which starts all the system services.
So many of these services are implemented as a daemon programs, the programs that just sit in the background
and do their thing without having any user interface.
So even if we are not logged in, the system is at least a little busy performing routine stuff.
So the fact that a program can launch other programs is expressed in the process stream as a parent
process producing a child process.
So the kernel maintains information about each process to help to keep things organized.
So, for example, each process is assigned a number called process ID and process IDs are assigned
in ascending order.
So with init always getting process ID one, so the kernel also keeps track of the memory assigned to
each process and these these each process readiness and resume execution here.
So like files persons also have owners and user IDs if and also effective user IDs and so on.
So let's actually start with viewing our processes right now here.
Clear.
And here you can view the process with PS command.
And as you can see, we get just two processes, right?
So the most commonly used command to view process and there are actually several commands and the most
common use is PS, So the PS program has a lot of options, but in its simplest form it is used like
this.
So the result in this example lists two processes the process 13709 and process 23501.
As we can see by default s doesn't show us very much, right?
So just the process associated with the current terminal session.
And to see more, we need to add some options.
However, before we do that, let's look at the other fields produced by P.
S.
So theta is short for actually let me write that down here.
So t.
He I.
Is short for teletype and refers to controlling terminal for the process.
So Unix is showing its age here, so the time field is the amount of the time field is the amount.
A of CPU time consumed by the process.
So as we can see, neither process makes the computer work very hard.
Right.
Actually and as you can see here.
So if we add an option like this, p x, and as you can see here, we get an A bigger picture of what
the system is doing.
So adding the option.
Note that there is no leading dash in this exception with just an X here.
So let's run it again.
Clear and ps6 X here.
So there's the x command we entered is without a dash.
So.
And this tells us to show all of our process regardless of what terminal, if any, they are controlled
by.
So the presence of a question mark here, the presence of the question mark in the team, as I said
to is actually teletype.
So the question mark is a column in this column indicates here, actually, let me take my marker.
So in this command, the question marks in this column indicates.
No controlling terminal.
So using this option, we can list every process that we own.
So because a system is running a lot of processes, PS produced, PS produced a long list, so it is
often helpful to pipe the output from PS into less so for easy viewing.
Of course.
So some options combinations also produce a long lines of output, so maximizing the terminal emulator
window might be a good idea too.
And in next lecture you will learn about more in PS and processes.
So I'm waiting you in next lecture.