Hey, everyone.
And welcome back.
In this video, we are going to talk about controlling our services, all the applications and the demons.
All right.
So service or applications, when they have started to create processes and when those processes run
continuously in the background, they become demons.
And I have explained that previously, what a demon is in detail and every aspect of a service, a process
or a script.
So more services that we run in our system are in a Linux environment and they run continuously.
There are demons.
Services are controlled by system.
Seitel Systems CTL is a System D utility that is responsible for controlling the system.
D System and Service Manager.
System D is a collection of system management demons, utilities and libraries, which serves a replacement
of System five and it d are in it demon.
So that was previously that was an it d, which was also a command that we used to run an older version
of Linux, which was a service.
But now that command service has been replaced with systems CTL or system control.
All right, System D is the parent process of most of the demons that we have in a Linux environment,
and the command to control all these services is a simple system CTL.
So every time you install an application or a package or a service in your Linux environment, then
you could control that program by running the command system CTL.
In this slide, I'm going to list some of the basic commands a system administrator should know to manage
a control to services.
First one is to check if System D is installed on your system, then check if the System DX is running.
Check all running services to check the status.
Start stop a restart of a service to reload the configuration.
File of a service to enable or disable service at boot time and your system shuts down and starts back
on.
This will allow the system to find out which service to start at that time.
A longer operating system then to enable and disable a service completely, regardless of boot or manually.
This is the command, so these are all the list of commands that we have and that you should know and
remember as well in order to control the services.
So I'm going to go over all of these commands one by one in our Linux system with you.
All right.
So I have my Linux machine open right here.
OK.
The very first thing is we need to know if we have the system installed in our system, our system D
comes by default installed on a Linux operating system version seven and eight.
And by the way, I'm referring to RedHat and CentOS operating systems.
So the earlier versions of the operating system might not have a system, be able, have a System B,
which had the init D mechanism.
So let's find out by running the command system CTL, Dash, Dash or hyphen hyphen version.
Right away, it's tells you this has a System D install with version 239 and it is 239 Dash 45 and L
we had, oh sorry, enterprise Linux eight.
That's what we are running now, depending on when you are watching this video and depending when you
have installed the Red Hat operating system on your on your virtual machine.
The version could be higher.
Or maybe you want you had it installed and you watching this video later than you might have an older
version.
It doesn't matter what you have, what version you have.
What matters is that you have System D package, our application that controls all your services have
installed.
All right, the next one is a check if the system is running.
If you have a system, do you running, then only then you could actually execute this system.
CTL commands, which controls these units, are, I would say the main is the system services and it
has the units.
So let's check ups minus EAF and grep for system or more specifically, System D.
Right here you will see the very first service or the process that gets started when your computer starts
or when your operating system start.
And this is the system D process.
And if you notice and to confirm that this is the first process that starts, you'll notice it has a
process ID of one.
This process actually initiates all the other major or minor processes of your system.
If you want certain processes, for example, Cron EDI, which is a time application to start a boot
time, the system is the one that you're going to tell.
Hey, this is a service called crony D.
I want it to start when the system starts, so it has all the other information as well.
It has its log in DH association.
It has this journalist session and all the other process.
Now, if you stop this process killed it, then it will kill pretty much your entire operating system
because all the other services that are that are running and your system depends are controlled by System
D..
OK, now moving on, then the next thing we have is check all the running services in your system.
So we have a lot of packages installed in our system.
What are those packages that are common to find out?
Those packages is r.p.m. dash key.
And it will list all the packages or applications that I have installed among Linux machine.
What are the total number I could do?
Pipe and WC minus L I have a total of thirteen hundred and seventy seven package install.
Now does it mean that every package that I have installed has?
It's a service loaded and started and running.
Now there are only few services that are running.
The other packages are just there in case it is needed, or you need to start it as an ad hoc or are
by request.
So what are the list of services do we have running or do we have enabled or not even started?
So for that, you will run the command system CTL, Dash, Dash all and automatically.
By default, it will give you one page at a time.
So here you have on line one to 25, and as you hit the spacebar, you will see all these services.
On the left hand side is status, but its configuration file is loaded or not.
And what's its current status at this time?
It's active and loaded, and it has a sub status which is plugged in if it's a plugged in or not, or
if it has another dependency on another system.
If this requires mounted like this boot up mount.
This is actually a service member.
We talked about the file system mounting.
It is mounted on slash boot, but.
To manage that process or to manage that mounting off that slash, but that is managed by your systemctl.
All right.
Moving on, for example, subsists a route up mount that is inactive now found dead.
It would try to install it.
This route is probably an older service.
It does not have a package, but it has a service, but couldn't find it.
Then you have other services as you go down right here, says Firewall, for example.
This is a firewall that allows you to protect your system from incoming or outgoing traffic.
So it says its configuration file is loaded beautiful.
The service is active and it is running so that it could be.
The service is up and so service could be active, but it's not running.
So this the third column is pretty much all the threads, all the sub processes that are needed to run
the web that service.
OK, if you go down, hit spacebar and you will see all the inactive load it all the services that are
actually available to us to manage by this system.
KTL.
OK, now the next one is to check the status of a service.
You could run the command systemctl status and it's moved to the right application dot service, which
the application itself right here will be replaced by the name of that service.
So in this example, what I'm going to do is I'm going to take the service off system.
Sorry, Firewalled.
So let's check the status of Firewalled Service System CTL status firewall D. This is the application
name, and we wanted to check its service, so I'll put a dot service.
OK, right away.
It'll give you all the information that you need, the servers, the configuration file right here is
telling you right here is a user lib system DX system firewall dot.
These is the service is a library.
It's loaded already.
It's getting all these instructions.
Now the actual status of the service.
Has it been started?
Yes, it has started is active and all the required processes that are needed for this service to be
active are those processes running?
Yes, they are running.
When was the last time they ran?
That's the date time.
And for 47 minutes ago, the documentation for this is right here.
If you click it, it will open up a page that will show you the documentation of this firewall.
D, The main process ID for Firewall D is 890.
Now, if you use the command right now, kill eight 90, it will kill this service.
But that's not the right way to stop the service, to stop the service.
What you have to do is sys CTL Stop.
Firewall D dot service.
OK.
It gave us ask us, are back without any error message, it means it worked.
Now let's check the status back again and now you will see the service.
The configuration file is loaded.
However, the active order, the status is inactive or dead.
It's not up and running.
You could also check the status of a service by running PPS minus if grep firewall D and you will see
there is nothing that came up only came up right here.
Please don't confuse this with actual service, because this is basically setting you the command that
I ran.
I ran a command grep and I wanted to grep for firewall and is basically bringing it back.
That command back to me that, hey, here's this process, because that commandment execute is a process
of itself.
OK, now if I wanted to start that service back again, hit up the arrow key and just simply replace
stop with the start.
All right.
It started, let's check the status again.
OK, there you go.
Status is loaded and it is up and running.
Now here's another one that you should know, which is restart right here now.
Restart, you need a restart is when you make changes to its configuration file.
Let's say you wanted to change the behavior of a firewall to how it functions.
Are you making Firewall Rd, allowing a port, enabling or disabling or anything that you have made
changes to the configuration file?
Then instead of you to stop and start, you could just use one command that is simply restart.
It will stop for you.
It will start for you.
All right.
Stopped and started.
How do you know it has came back online again?
Status and status will give you that information.
The right here.
This is pretty much a quick log which tells you when you executed the command.
What happened?
All succeeded.
Firewall D stopped firewall.
These started and all the information that it pertains to the firewall.
The service.
OK, now what if you are trying to stop the service from here and you cannot stop?
Something is wrong.
That's when you have to actually come and kill that service.
So you could do kill the main process ID, which is three seven four two seven hit enter and it is killed.
Now, if you wanted to check the status you see right here, it says loaded.
But the service.
Is it active?
OK, so as I said, killing or using a command kill is not an efficient way or a graceful way to stop
a server.
The best way to stop a service is by doing systemctl.
Stop anyway to start it back again.
We could use start and it should start back again.
Let's check the status and it has been started.
Next one is we will talk about to reload the configuration of a service.
What is a reload or what is a different between stop, start or restart and reload?
OK, so reload is not going to impact your service when, whereas stop and start will impact your service.
If you are running a service, for example, Apache Apache service name is h t h http.
So as soon as you make a configuration changes on Apache and you stop it, then you are going to lose
the page.
Anybody is who's on your website, you will lose it and until you restart it.
But if you're making changes to your configuration file and you use the command reload, then it will
reload the configuration file back again to systemctl without stopping and starting the application.
That's the beauty of reload.
We could run it just to for the demo purposes.
Reload and it is reloaded.
OK, now moving on is to enable or disable a service at boot time.
So if you want this service to boot while your operating system boot, or in other words, if you want
Firewalled to start when your operating system starts with that, then you have to enable that service
to enable it.
You could just simply type systemctl enable and it will be enabled at boot time.
Now, if you wanted to have, by the way, how do you check if it is enabled and not, you could do
the system Ctrl and right here on the loaded right here is is enabled.
That's when it's good to tell you the status.
See, right here it is enabled.
OK, now if you wanted to disable it, Mitch means that you don't want it to start when the operating
system start to simply, there are a couple of links that it has to remove.
But anyway, let's check the status and you will see it is disabled now.
If you reboot your entire operating system, it will not start your firewall service, but it doesn't
impact the existing state.
OK, so let's clear the screen.
The next one we have is to enable or disable this service completely.
And you probably thinking isn't the same one we just covered to enable or disable at boot time?
Well, yes and no.
Yes, it will disable if you choose to disable a.
Boot time doing the operating system.
It will not boot the service, however, it is possible if service, for example, a has a has to start
and it requires another service.
For example, Service C to start with it, then regardless, if that is enable or disabled, it will
start that service.
So, for example, let's talk about in a real life situation, for example, if you have a chronic or
even HTP service that it starts now, that service requires to start another service that let's say,
you know, example Firewalled.
Then, regardless, if the firewall dies, enable disable, it will start now.
If we have that service masked or unmasked, then.
Doesn't matter which service, try to request for that service to start, it will not start.
That's pretty much a simple and straightforward differences.
So if you do a system settle and we do, for example, start again on no status to check Firewall Rd.
Service, you see, it's up and running now to unmask the first, let's see if it has mask, let's create
a symbolic link now to unmask.
You could just simply type on mask and remove the symbolic link.
Now, if a service comes in at it, wire service be to start and that Service B has been unmasked,
then it will not start regardless what that service instruction comes in with.
Anyway, these are the few commands that you should remember, especially the systemctl is the main
command.
You could always find the different options off that and which service to stop and start by.
System TTL, Dash, Dash or every service that you have to start and stop is managed by System TTL or
many times.
Nowadays, the third party applications can be managed to systemctl command or service as well.
I'll see you in the next lecture.