centostargetsystemdrunlevel

How to set target (runlevel) to service in CentOS7 (Systemd)?


I want to set target to service in CentOS7 (Systemd). I want to know following.

In other words, I want to know substitution for following commands.

$ sudo chkconfig --level=2345 mysql on (<- set runlevel)
$ chkconfig --list mysql (<- show runlevel)

I understood that "runlevel" in CentOS6 changed "target" in CentOS7and I should use "systemctl" command.

But problems were not solved.

I heard that following command is replacement for "chkconfig --list" , but I can't check target and can't set target.

systemctl list-unit-files

Solution

  • Setting the target is done in the unit file for the service. For example:

    [Install]
    WantedBy=multi-user.target
    

    Then you run systemctl enable $service_name to create a symlink which enables the service to start as part of a particular target. You could also create the symlinks manually. The enable command will print out the paths of the symlinks it's creating.

    I think systemctl --reverse list-dependencies $service is the way to find what services and targets depend on a specific services to boot.