systemd alternatives to ‘service’ ‘chkconfig’ and ‘init ‘ commands in CentOS/RHEL 7

The systemctl command is used to interact with systemd and can be used to list systemd unit information and manage services.

NOTE that this is different from the sysctl command.

 

MANAGING SERVICES

 

1. List manageable services

 

List all service units with the command:

# systemctl list-units --type service

 

2. Starting a service

 

Upstart Command: ‘service crond start’. The equivalent Systemd command is:

# systemctl start crond.service

 

3. Checking the status of a service

 

Upstart Command: ‘service crond status’. Systemd Equivalent:

# systemctl status crond.service

 

4. Stopping a service

 

Upstart Command: ‘service crond stop’. Systemd Equivalent:

# systemctl stop crond.service

 

5. Start service on boot

 

Upstart Command: ‘chkconfig crond on’. Systemd Equivalent:

# systemctl enable crond.service

 

6. Do not start service on boot

 

Upstart Command: ‘chkconfig crond off’. Systemd Equivalent:

# systemctl disable crond.service

 

MANAGING TARGETS(RUNLEVELS)

 

The table below indicates the target names for each SysVinit/Upstart ‘runlevel’

Runlevel Target Units
0 poweroff.target
1 rescue.target
2 multi-user.target
3 multi-user.target
4 multi-user.target
5 graphical.target
6 reboot.target

 

1. List Runlevels/Targets

List all target units with the command:

# systemctl list-units --type target --all

 

2. Print the default target

# systemctl get-default

 

3. Change Runlevels/Targets

Change the default target to ‘runlevel 3’:

# systemctl set-default multi-user.target

 

Switch to ‘runlevel 3’:

# systemctl isolate multi-user.target

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)