Processes and jobs, before we get into this lesson, I want you to understand what exactly each term
means in the Linux environment.
Well, first we have applications which are also referred to as service, an application or a service
as like a program that runs in your computer.
And then application could be anything like in Windows, you have Microsoft Word, PowerPoint and then
you have programs or applications like A.P. and EF-S, Apache and whole bunch of different programs.
So that is an application and service that runs on your computer.
Then you have a script.
What exactly a script is a script is something that is written in a file and then packaged it to in
a way that it will execute.
So any application that is running in your computer, for example, Apache, you would have to run that
as a script and that will run in the background.
So that's actually a script.
And also all those different commands that you run in a Linux environment.
All of them are also up for two scripts.
Then we have a process.
What is a process?
When you run an application or when you start up an application, it actually generates a process where
this process ID now processes could be one associated to that application, or it could be multiple
processes.
Then we have demon.
The demon is I could tell you when I compare it with the process is something that continuously runs
in the background or it doesn't stops.
So when you run a demon, which is also a process, but it keeps on running the background and it keeps
listening to the incoming traffic or outgoing traffic.
Then there is a thread or threads every process could have multiple threads associated with it.
An application that is running in your background, let's say an offense when you run that application
in your Linux machine.
It could have many multiple threads.
If a machine, a remote machine, tried to connect to you through an office, it will generate one thread
for it, and it will generate a second thread or third rate for other computers that attaching to it.
Then we have a job, a job as something that is created by scheduler like a work order to run those
applications and services.
All right, guys.
Now it's time to look at the monitors that we have available to manage our processes, so when an operating
system boots up, many programs get loaded into system memory.
These processes or you want to call them programs, need to be managed and monitored very closely because
they consume mainly three system resources, and those resources are CPU memory and disk space.
If they are mismanaged, then system can stress out and shut down on you and application and your production
applications can actually break.
All right.
So what are those monitor or the commands that we have available to us in our learning system?
So let's take a look here.
The very first one is DFA, which actually monitors or actually gives you the statistics on your file
system.
Then you have disk usage, which gives you the how much usage of the disk is being utilized by each
file.
Not just a file system, but by each file.
Then we have uptime, which tells you the system, how long it's been up for.
Then we have top command command, a lot of things that we need to cover in top free.
LSC 0f our list open file system.
TCPDUMP Netstat.
Police Command.
Kill Command and some other commands such as VM STAT is that if top, etc. So these are a few commands
will go over real quickly.
So stay with me and we'll we'll cover them one by one.
So I have my Linux system open up right here.
OK, so I am logged in as who am I as a root?
And I'm logged into my system called my first Linux VM or whatever the name that you have chosen.
All right.
Let's start with the very first command, which is ADF command.
Before I run the command, I want you to run a man ADF command and quickly skim through what is the
description about what is the name or what are the different options that are used with that command?
So if you hit space bar, it will bring you down to the second page.
You will see all these options that are available, which each each with each of that command.
If you want to get out of the manpages, you know, just simply hit key and we'll get out now.
As it mentioned in man, it actually reports file system disk usage space.
So we have a file system in our Linux system.
And how do we check that file system and how much disk space that is utilized in that you could just
simply run ADF command?
This will give you the file system name, the size and kilobyte, the usage and availability usage and
mounted on which mount point.
So if you just run ADF command, you will see that in the end kilobytes.
I would recommend that you always run with the Option D f minus h h, meaning human readable.
So hit enter and you will see right here the file system, the size that gives you three and 176 meg
used available percentage and mounted on.
So now it's lot easier to read than just the number.
OK, so as you notice here, if you go by column by column, the first one is the file system.
This first column you see devel tmpfs, tmpfs tmp first three of them.
Then we have this dev mapper.
Well, my first Linux VM root, which has the size on it, which will cover in a second.
And then we had the last file system is dev SD one.
All right.
So the first four of them, this dev tmpfs or just dev or just tmpfs, these are file system for your
swaps space.
Our Swoff space has been carved out for two gig.
How do we check the swap space, which we will cover in the next few commands when we go through it?
So from here till down, everything is so off space, but the real filesystem that you wanted to cover
is these two.
OK, so let's focus on these two.
The first one is tell you the file system.
The second one tells you the size that we have carved out for that file system, which is 17 gig.
How much is is used out of there?
Seventeen four point eight gig only.
Well, how much we have available or left.
13 gig.
How much is used in percentage.
So basically, this is percentage into what we have total ditches 29 percent and where is it mounted
to?
It is mounted on our main root file system, which is slash.
The second file system is dev sda1, which is one oh one m, which is the one gig.
If you convert that into gig and used as 02:44 available at the 771 24 percent and boot.
This is the file system that's given to our boot or whenever you boot up your Linux system.
There are certain files that are located on slash boot to the operating system will go into slash boot
and find at those files.
And boot up your system, how the system boot up works that will be covered later on in Red Hat or RH
134 S..
All right.
So this is a DFA minus h command.
Let's move on to the EU command.
By the way, if you see there's usage somewhere here which says 98 percent, 100 percent, it means
you file system is getting full and you need to find out why it is getting pool.
That's when the second command comes in.
Let's say if you want to know your slash file system is 100 percent and you want to know which are which
individual file is actually causing or is the culprit that you could delete to reclaim your space.
That's when you use the Command D you, which is disk user.
So you do, man, do you and you will see right here estimate file space usage, though now this is
not by default space file system, it's about the actual files.
So if I do, d you.
And I will do on Slash.
You will see each an individual file that is in my operating system with its size and it goes so fast.
So it's very hard to read.
So what I do is let's control see out of it.
What I would do is do you minus K for kill or bite and then slash again, it will give me a lot of them.
A lot of all, the file system and kill kilobyte still not easy to read.
So what I will do is hit up arrow key.
Then I will pipe it to short end reverse order and then before it goes to many, falls in one shot on
the screen, I will do more.
So this is going to give me the file usage in kilobyte of root file system in reverse order, meaning
the highest number will be on top and I will one page at a time.
OK, let's move this down.
Let's hit enter.
OK, now it's going through some calculation when you see this message coming up as no file system.
Let me move up right here.
No such file or directory.
Just ignore it.
These are the files that are in the system process when you see proc to just simply ignore it.
All right.
Right here, as you see, the very first directory that is using the highest disk space is right here,
you root.
OK.
So this is, I mean, directly where everything is mounted.
We know that next the highest disk usage in our system is user within user.
There's a directory called share with and then there's another dirty 64 and so forth.
Now, if you wanted to get that due in kilobyte and so kilowatts, you wanted to get in human readable
again, just like DBF, you could also do h and hit enter.
And this will go through again the same thing.
Ignore cannot access no such file or directory messages.
And right here you are going to see the human readable 1000 K kilobyte.
Where is it?
User share microcode, blah blah blah.
This is a file named S4's using A-Z.
As you scroll down, you're going to see the size is going to go down because we have sorted into reverse
order.
See you right here.
This is all it's going to tell you, what are the files and then you could simply tell, Hey, this
is the file that is taking up all that space.
So I am going to delete that file to reclaim it.
But of course, before you delete it, make sure you check with the file owner or make a backup copy
some on another server.
And this way, you don't delete any important file accidentally.
All right, so this is about DFW.
Let's clear the screen, by the way, before I move on.
I wanted to show you another option of DFA command, which is Ti.
Sorry?
Uppercase, the uppercase t actually tell you what type of file system we have.
So there are different type of file system in Linux.
There is a X-T3, X-T4 and ex-first.
So if you want if you're looking for a file system type, then you type D of minus uppercase t0 give
you temp office temp f's.
Except this c right here, this one will give you the file type.
All right, let's move on.
The next command we are going to covers up time man uptime, and this tells us, tell you how long this
system has been up and running.
So if I have rebooted my system just now, it is going to tell me the time it's been up.
So if I do uptime, you will see my system has been up since this.
This is the right existing time and it has been up for 41 minutes.
The number of users that's been logged in since I've been up or logged in right now is one user load
average.
The system load average in percentage the last minute.
Five minutes and 15 minutes, respectively.
It's very important that you run up time if your system is running slower, response time is slower,
someone complaining that it's very slow or sluggish, you come in.
You type up time and you will see the low to hear that it's most likely it's going to be higher.
All right.
Next command and every system administrators favorite command and that is top.
Before you run the top command do man top and you will see the information about the top display Linux
processes.
All the processes that you are running on your Linux system will be displayed by running the command
top.
And if you want to find out more information or description of top, simply read through it.
There are many, many different options with the top.
It's a command that offers many, many features within itself.
So let's go right into the top command hit top and type top and hit enter.
All right, I'm going to go very quickly with this top command because if I have to go through every
single detail, it could take me hours to explain.
So I'm going to go through the basic and important stuff that you should know.
The first alliance is the command.
The time right now the system has been up and running.
One user load average.
If you remember, this same line is available to us from the uptime command second line tasks total
task that we are running in our system of processes.
Two of them are running 188.
Our sleeping zero stop zero zombie CPU CPU is 3.7 and there are different system information about the
CPU idle.
Wait, hi, if your CPU right here comes up as, for example, 95 percent, then definitely means something
is wrong with your system.
And there might be a process right here which we'll cover in a second that is causing your CPU load
to go up.
Then we have memory, total memory right here.
We have one or nine.
This is in Meg.
If you if you divide that we 1024, you're going to see most close to one gig.
That's what we carved out for physical memory free.
121 498 is in used buffer size cache size.
Next one is swap space.
We have our operating system carved out to swap space for Linux system, which is to gig.
Total is free right here.
13 Easy to use six six five Available Memorize right here.
Now, let's come down to these columns.
These column I have an information right here on my quick document right here so that it will give us
each columns.
Information, the very first one is the process.
Every time you run a process in the next system, the operating system assigns an ID to that process
and that ID is shown right here.
The reason you see that ID is so if you wanted to stop that process, you could stop it through by the
process ID and you could use the kill command, which will cover in a few seconds to kill that process,
if that is something you wanted to stop.
And free up the resources.
Next one is user simple who owns that process or who started that process, as you see most of that
process right here on Beirut.
If I'm running a process in the background, for example, if I'm running, another top command right
here is telling me I'm running the top command and who is running the document route myself is running
a top command.
So this top command is tell is telling it about itself.
Next one is PR process priority.
Each process can be assigned a priority depending on how CPU handles that process.
Which one comes first?
Next one is an AI the nice value of the process.
Second, there.
Sorry.
One two three four fifth one is a virtual amount of virtual memory used by a process, then amount of
resident memory use by process, which is this local amount of shared memory used by a process.
Then we have status of the process.
There are many status sleeping and then are for running and their other process statuses, which I don't
remember.
On top of my head.
But you can look it up online and you will find all the statuses of information.
Then simple this this column CPU percentage.
This one is the one that you need to look at if a process that you see right here.
This is going to be the name of the process where you see command.
If that process is using up, for example, 95 or 100 percent CPU right away, you could tell, Hey,
I know which process is causing the the problem for our system.
What I'm going to do is I'm going to kill that process.
Same thing with memory.
If it processes using a lot of memory, it will show up right here and you have to go and kill it and
time it's been up for and command the name of the command of that process will be shown right here.
All right, now, that's about the top, as I said, a top has a lot of information to offer.
And I would highly recommend you to spend more time to learn about the process, learn about the top
command and its other options by going to the man command or if you will look it up online.
Be my guest.
If you wanted to get out of the top command, just simply hit key and you will get your prompt back.
Next command is free.
Free will give you the information about your memory.
So we talked about CPU memory all in one top can give you that.
Or if you want to be Pacific to find out only about your memory, you just type free.
If you wanted to see the free or the memory information in megabyte, you type minus important megabyte
and it'll give you the memory size in megabyte.
This is the physical memory we have, which is 109 that we have assigned when we built our system.
So if I go to my Oracle VirtualBox, go to settings.
Go to system and in the memory seized, write his best memory one zero two four.
This is the memory that's given to my Linux machine, and it rounded up something around one, eight
or nine, so we know it is close to one gate.
Then this is a swap space that's given to the system by operating system when we install the operating
system.
The operating system.
Itself carved out swap space for itself and swap space is actually a space that is on the disk.
It is not a dedicated memory, like a physical memory, like a dim on a system, it's actually a space
carved out on a disk.
If I do d f minus h again, you're going to see right here.
This dev, as D1 is one gig, this is this memory, whereas this swap a virtual disk, this is carved
out from the swamp.
Why, if you notice right here?
Deb Mapper, this is 17 gig when we actually created the file system, sorry, install the operating
system.
You go to setting, you go to storage and you're going to see right here we we actually built the system
with 20 gig, right?
So why is showing 17 gig?
It's because one gig was given to the boot file system by the operating system that left with two gig.
Where did that to go?
The two gig was assigned to swap right here when the operating system was built.
Now 17 plus 18 plus 220.
Now we know where that 20 gig this space is.
All right.
Moving on from a free to LSD effort, which means a list open file.
So when you are running a process, a process most likely will go into certain files and certain configuration
file to look what it needs to do.
It needs some instructions.
So sometimes when you are when you stop a process, the files that it was looking into remain open,
which can also cause a system to break or slow down, so you could find the list of open files by running
the command.
Alice o.f But before we do that, do man, elsewhere you get more information.
List open files and all the options that are available with that command.
If you just simply run Alice, or if you're going to find a bunch of files right here, which goes through
so much because we have so many processes running so each process could have multiple files open.
If it is actually asking hardware to print something, asking mouse to move or asking keyboard to type,
it's actually going through each file and touching that file.
All right, then we have the next command tcpdump, one of my favorite command.
This is specifically for networking.
So what is coming?
Which activity coming into the system, which traffic going out of the system?
This is the command will tell you everything.
So if you simply run tcpdump, you're going to see this bunch of information coming in and out of your
system.
So you probably you're going to have a hard time reading it.
So let's control C and let's look at it, and it's going to tell you the time.
The IP address, where is it coming from, what's the gateway?
What's the broadcast information so much?
What I will do, which is my favorite option.
First, I need to find out which what is the name of my interface for that out to run command?
If config and it will tell me this ENP zero S3 is my interface, so I'll do tcpdump minus I and then.
ENP zero as three.
It means I wanted to see all the traffic that are flowing over this network interface.
I don't want to know any of the traffic that happening internally, which is local or on the virtual
adapter.
I just wanted to see tcpdump network traffic coming in and out of this interface hit enter.
You're going to see all information again.
There's so much going in, so much coming back that you will see.
See, right here, this is the traffic coming in, coming out.
This is the iPad for my son, who is connecting to my computer as well.
This is the name of our Linux machine and is going to my router.
What are the traffic coming in?
What is the protocol?
There's so much information that you could get, and if you are troubleshooting to find out what is
coming into your system, what is going on to your system.
This is the best command that you could get.
Let's clear the screen moving on to the next command, which is netstat to man netstat.
It will give you that information.
This is also related to your network statistics or anything coming in and out.
What are the connections has been established?
Who's your router?
Who's your gateway and stuff like that?
The first command outside of first options that you should run with netstat, which I run every time
I configure the interface, which is R and we hit enter, it will give you the information how your
network traffic or which gateways are flowing through my gateways 10 253, one one.
All my traffic that's coming out of this Linux machine that you see, that's where you have a 0.000.
All that traffic will go through the Gateway, which is right here, subnet mask, which interface is
going through and so on.
Other information, other gateway.
Every traffic that I have on tend to 1.0 should go to this gateway.
And this gateway comes up here and this traffic goes to this gateway.
A lot of information this read and go through each of the each and every column.
Also, you can run netstat minus a, which will give you all the connection information that is connected
to outside.
You could also run ATC netstat to you.
This will give you all the UDP traffic.
If you want to check the TCP Traffic Assembly simply type T, it'll give you all the TCP traffic that
it's listening to.
Let's move on to the next one.
Let's clear the screen.
The next one is PSA.
PSA is processed status man.
PSA report a snapshot of the current process of all the processes that are running in our system.
It will give you the list of those processed, just like in top and you run the top.
You see all these processes, but it will give you the highest running prices on top.
But there are so many other processes as well that's only taking point 0.0.
What if you wanted to delete a process that is processed ID, for example?
Thirty one is not showing up here.
So what we could do is we'd run the command aside with the option minus f command, and it will give
us all the process that we have running right here.
See?
OK.
If you wanted to if you want to find out information about a Pacific process, then you could also do
this if if is one of the options that you could find out from the man command.
This is one of my favorite options that I use.
So you could do more to view one page at a time or if you wanted to grab a grip something, you could
do it right here.
Grab Top.
So I wanted to know if there is any process that running with the command top, so there isn't anything
because I stopped the process.
So now what if I open up another terminal?
Where did it go?
And.
OK.
Right here.
New Window.
OK, sorry about that.
I guess when I click on the terminal, it actually takes me to the existing terminal.
If I wanted to have a new terminal, then you could go to terminal and click on New anyway.
You think we learn every day?
All right.
So Nat, say if I'm running top command here and now, this top command actually has become one of the
process.
Now, if I wanted to know if there is any process running with the name top, I could do minus f and
grab for top and right here you will see this is the process that's running.
Right here in the background in this window now you're probably wondering, hey, how come Imran, there's
another process right here which shows up.
Now the funny thing is that when I execute this command piece minus C.F. and grab for top as soon as
it execute it, it becomes it's up its own process, so it actually grabs its own running process.
So I ran, Hey, give me s minus f a result that has this tops.
That's what it gives me this top right here.
But the actual process that's running in the window behind me is right here.
Now, if I wanted to stop.
This process.
I could just simply do que.
And it will be gone.
And when I come back to this window and do my desktop, you'll see this process of running right here.
It's gone.
It's no longer there.
So that's one way to stop.
What if there is a process that's running and I'm trying to stop the process gracefully, but doing
queue or something?
And it's not stopping.
My heft top, and it's not stopping then comes in the next comment, which is right here Kill Command,
you could use the kill command to kill a process right away.
So if I wanted to kill this process as running behind me right here, I could just simply do kill and
specify the process idea.
Remember, I told you the beginning, the process.
It will help you to pick up to kill a process, identify the process and kill it.
Three.
Three, four, four four eight.
Hit enter right away at the back, you're going to see you got your property, see it killed.
That process right away.
So that's what the killer does.
But if there is another powerful option with kill, if you're trying to kill a process and process is
not getting killed, then you could use a kill minus nine option, which would not look here and there,
which will just go and simply kill it harshly.
It will.
It will not kill.
It will not go through the graceful killing process.
It will actually kill all the associated process with that.
So that's what the kill command is.
The other commands that are available to you when you're going through your system monitoring.
There are a few of them, for example, VM stat, IO stat, if top and a few others, I'm sure you're
going to find third party utilities as well to keep your system monitored healthy.
I'll see you in the next lecture.