Blog Post
RedHat RHEL/CentOS 7 Service Start Up Changes
Author
Mandy Doward
Date
September 7, 2016
Length
3 mins
RHEL/CentOS 7 Has A New Initialisation Daemon
The init daemon is the initialisation daemon first implemented in System V UNIX systems and has been around for over 40 years!
RedHat’s RHEL 7 and CentOS 7 introduces a replacement for init called systemd.
Startup & Run Levels
RHEL 6 (and CentOS 6) supported SysV init and Upstart with start and kill scripts created as links to scripts in /etc/rc.d/init.d scripts in the appropriate run level directory e.g. /etc/rc2.d.
RHEL 7 (and CentOS 7) implements system and service units, managed with the systemctl command.
The service command can still be used to bring services up and down as in RHEL and earlier, but is only provided in RHEL 7 for backwards compatibility.
service Command (6)
systemctl Command (7)
Description
service name start
systemctl start name.service
Starts a service.
service name stop
systemctl stop name.service
Stops a service.
service name restart
systemctl restart name.service
Restarts a service.
service name cond restart
systemctl try-restart name.service
Restarts a service only if it is running.
service name reload
systemctl reload name.service
Reloads configuration.
service name status
systemctl status name.service, systemctl is-active name.service
Checks if a service is running.
service --status-all
systemctl list-units –type service –all
Displays the status of all services.
Changing Run Levels
The traditional init based systems implement run levels. The new systemd based systems work with targets.
Run Level (6)
Target (7)
Description
0 runlevel
0. target, poweroff.target
Shut down and power off the system.
1 runlevel
1. target, rescue.target
Set up a rescue shell.
2 runlevel
2.target, multi-user.target
Set up a non-graphical multi-user system.
3 runlevel
3. target, multi-user.target
Set up a non-graphical multi-user system.
4 runlevel
4 .target, multi-user.target
Set up a non-graphical multi-user system.
5 runlevel
5.target, graphical.target
Set up a graphical multi-user system.
6 runlevel
6.target, reboot.target
Shut down and reboot the system.
Shortcut Commands To Change Run Levels and Targets
The following commands are quick ways to change the run level or target of a Linux system.
Command(6)
Command(7)
Description
halt
systemctl halt
Halts the system.
poweroff
systemctl poweroff
Powers off the system.
reboot
systemctl reboot
Restarts the system.
pm-suspend
systemctl suspend
Suspends the system.
pm-hibernate
systemctl hibernate
Hibernates the system.
pm-suspend -hybrid
systemctl hybrid-sleep
Hibernates and suspends the system.
Working With Targets
Check the Default Run Level or Target
For init based systems the default run level is defined through an entry in the /etc/inittab file. The line with a label initdefault defines the run level the system will boot to by default.
The new systemd based systems use the systemctl command to set and check the default target to boot to.
List the Active Targets
Change the Default Target
If you have any questions about Linux email us at info@ptr.co.uk and we would be happy to help, or if you would like to learn more about Linux take a look at our Linux courses and UNIX courses.
Share This Page
Mandy Doward
Managing Director
PTR’s owner and Managing Director is a Microsoft MCSE certified Business Intelligence (BI) Consultant, with over 30 years of experience working with data analytics and BI.
PTR FAQs
See our FAQs or get in contact for more information on any of our services, solutions, or to start your PTR journey.