Tag Archives: rhel7

Controlling RHEL 7 Services

One change from RHEL/CentOS 6 to the RHEL 7 beta is how services are controlled. The old service and chkconfig commands are replaced with systemctl. These are my quick and dirty notes compiled from the Fedora Project systemd and SysVinit to Systemd Cheatsheet pages.

Basic Control

The old system command’s replacement is very similar, with services having .service appended:

[bash]
systemctl start|stop|restart|status name.service
[/bash]

For example:

[bash]
systemctl restart httpd.service
[/bash]

Service Boot time Control

To get a list of available services and their boot time status:

[bash]
systemctl list-unit-files –type=service
[/bash]

To set a service to start (or not) at boot time:

[bash]
systemctl enable|disable <em>service</em>.service
[/bash]

For example:

[bash]
systemctl enable mariadb.service
systemctl enable httpd.service
[/bash]

Run Levels

Run levels are called targets, have been simplified, and have names now. An incomplete list:

  1. poweroff.target (run level 0)
  2. rescue.target (single-user mode; run level 1)
  3. multi-user.target (normal run level 3)
  4. graphical.target (normal run level 5)

To set the default run level:

[bash]
systemctl set-default multi-user.target
[/bash]

To change the run level:

[bash]
systemctl isolate name.target
[/bash]

For example, to enter single user mode:

[bash]
systemctl isolate rescue.target
[/bash]

And the appropriate services will be stopped and started.

Additional Reading

  • A description of how systemd fits into the boot process here.
  • Another nice summary here.

Updates

2014-07-17
Updated setting the default run level per CertDepot’s suggestion. Added the “Additional Reading” section.