Now let's look at starting stopping and checking the status of network services.
And Linux,
most servers have at least a few services running on
them that deal with network data in one way or another
one example is the SSH daemon running in the background and
listening for incoming network connections to let people log in remotely.
Let's see how we can inspect what programs are
currently running and waiting for incoming network connections.
There are two utilities we can use
SS and netstat.
Now dash L lists what's currently listening for connections.
Listen in this context means that something is scanning for incoming network data
and ready to accept an incoming connection.
T lists TCP connections.
You list two
P connections
dash in lists, numeric values.
That's because we need root privileges to explore processes
owned by root that are listening for incoming connections
to easily remember all five of these options. LT UN P.
You can think of this
listening
TCP UDP numeric process.
Another trick to remember these options is to
recognize them and write it in a different order
like this
where it's T UN LP.
And you can think of T UN LP tunnel programs
as a quick way to memorize the five letters.
If you ever forget the right options, just enter SS dash dash help for a quick refresh
in the output of our command.
We can first take a look at the local address and port column,
an entry like this means the program is listening for
incoming connections from the system itself but not other computers.
127.0 0.0 0.1 is the IP address for the so called localhost.
Basically the same computer. The program is running on
this way, a web server application like Ingen
X can connect to a database server like Maria DB.
If they're both running on the same computer
engine,
X can connect to 127.0 0.0 0.1 port 3306 and talk to
Maria DB in a way Maria DB is in a protective bubble.
It protects connections only from programs running
on our server but ignores connections coming from
external devices to see what is listening
for connections coming from the outside world,
like any computer on the network or the internet.
We can look for entries like this.
And this shortcut means the same thing as 0.0 0.0 0.0 colon 22.
It just indicates that this is listening
for incoming IPv6 connections instead of IPv4.
So the SSH daemon accepts connections on both the IPv4 and the IPv6 protocols.
In this case, finally,
we can see that connections on port 33 and six
are accepted by a process called Maria DB D.
That is the Maria DB daemon. Our database server application
also connections on port 22 are accepted by our
SSH daemon running under a process called SSH D.
There are good hints on what we can explore next
to check the status of these network services. We can use the system
CTL command,
systemctl status. Maria DB dot service
and system CTL status SSH dot service
note that we omit the D letter at the end which stands for daemon,
the service names on
Ubuntu just use the name of the program itself.
But on other operating systems like red hat services do have that D letter at the end.
So what is SSH service on
Ubuntu is SSH D service on Red hat
now to stop the Maria DB service, we can use the usual system CTL stop.
And if we check it with our SS command
again,
we'll see connections are no longer accepted on port
3306 as we just close the database server.
And of course, we can also disable the service from autostarting at boot
with this command
and we can enable it to autostart
and then start it up again with this command.