[
181
]
Another thing you may notice in the screenshot is that the name of the
ssh
unit is
actually
ssh.service
, but you don't need to include the
.service
part of the name,
since that is implied by default. Sometimes, while viewing the status of a process
with
systemctl
, the output may be condensed to save space on the screen. To avoid
this and see the full log entries, add the
-l
option:
systemctl status -l ssh
Another thing to pay attention to is the
vendor preset
of the unit. Most packages in
Ubuntu that include a service file for
systemd
will enable it automatically, but other
distributions typically don't start and enable units by default (such as CentOS). In
the case of the
ssh
example, you can see that the
vendor preset
is set to
enabled
. This
means that once you install the
openssh-server
package, the
ssh.service
unit will
automatically be enabled. You can confirm this by checking the
Active
line (where
the example output says
active (running)
), which tells us that the unit is running.
The
Loaded
line clarifies that the unit is
enabled
, so we know that the next time
we start the server,
ssh
will be loaded automatically. Although
systemd
units are
typically enabled and started automatically in Ubuntu when installing their package,
this can still vary. When you install a new package, make sure you check the status
of the unit whenever you install a new package, so you'll be aware of its settings.
Starting and stopping a unit is just as easy; all you have to do is change the keyword
you use with
systemctl
to
start
or
stop
in order to have the desired effect:
sudo systemctl stop ssh
sudo systemctl start ssh
There are additional keywords, such as
restart
(which takes care of the previous
two command examples at the same time), and some units even feature
reload
,
which allows you to activate new configuration settings without needing to bring
down the entire application. An example of why this is useful is with Apache, which
serves web pages to local or external users. If you stop Apache, all users will be
disconnected from the website you're serving. If you add a new site, you can use
reload
rather than
restart
, which will activate any new configuration you may have
added without disturbing the existing connections. We'll take a look at Apache in
Chapter 14
,
Serving Web Content
, so don't worry too much about Apache right now.
It's just a good example of a unit with additional functionality. Not all units feature
a
reload
option, so you should check the documentation of the application that
provides the unit to be sure.
Controlling and Managing Processes
Do'stlaringiz bilan baham: |