DEV Community

Frank Promise Edah
Frank Promise Edah

Posted on

How to set up systemd targets in CENTOS

Image descriptionYou have been handed a server that needs to be customized according to a specific standard. complete the following objectives

OBJECTIVES

  1. carryout a check list on the default target in order to make sure the custom target you will create works.
  2. Your custom target should be identical to your default target. Except that it should want httpd service.

Experience level
Basic

  1. verify default target
    To verify default target: systemctl get-default
    To set it to multi user target: systemctl set-default multiuser.target_
    To isolate the target: systemctl isolate multiuser.target

  2. CREATE custom.target
    a) Change directory: cd/etc/systemd/system

b) create a file by copying multi-user.target into custom.target: __/usr/lib/systemd/system/multi-user.target ./custom.target

c) open the file: nano custom.target
d) Edit the [unit] section:
[Unit]
Description=Custom Target
Documentation=man:systemd.special(7)
Requires=basic.target
Wants=httpd.service
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes
e) use the ctrl X option to save and quit
check if httpd is already installed in the server: rpm -q httpd_
if not installed, do yum install httpd -y

f) isolate custom.target
g) check status of httpd: systemctl status httpd

If we try to isolate into multi-user.target, we will see that httpd is dead because it is not set up to want Apache service.

Top comments (0)