Home Topic Networking LFCE Prep Course: System Services (Part 5)

LFCE Prep Course: System Services (Part 5)

0
LFCE Prep Course: System Services (Part 5)

Start exploring Linux Networking and Administration by downloading the free sample chapter today. Download Now

 

Welcome to part 5 of our Linux Foundation Certified Engineer Training Course sneak peek blog. In today’s offering, we look at commands for starting, stopping system services using init, upstart, and systemd, and managing transient system services with xinetd.

In parts 1 and 2 we reviewed the OSI network layers. Part 3 covered basic network topologies: local area networks (LANs), wide area networks (WANs), virtual local area networks (VLANs), and bridged networks. And, in part 4, we covered the different types of DNS servers and reviewed command-line tools.

System Services

Many system services are provided by daemons which run at the Application Layer. Different initialization systems have been built to ensure that system daemons are running. Some of these systems are:

  • init (commonly referred to as SYSV init)

  • Upstart

  • Systemd

System V Init Scripts

System V init scripts are shell scripts used to start services. Using serial execution, dependency management is done serially. The execution order and dependencies for SysV init scripts are managed by renaming scripts to run in proper order. Long boot times are due to serial execution.

BSD Init Scripts

BSD init scripts are shell scripts used to start services. They use serial execution and the dependency management is done automatically. The execution order and dependencies for BSD init scripts are managed with dependency tags in the scripts themselves. The command rcorder reads these tags and prints out the proper order. As with SysV init, the boot system is still done in series, leading to long boot times.

Successors to Init

To counteract the problems with historical init systems, different systems have been developed.

Systemd:

Fedora (Since Fedora 15)

Mageia (since Mageia 2)

OpenSUSE (Since 12.1)

RHEL (Since 7.0)

Debian (Since 8.0)

Ubuntu (Since 15.04)

Upstart:

Ubuntu (since 9.10)

WebOS

RHEL (RHEL 6.X only)

Fedora (Fedora 9 to Fedora 14)

Various other lesser used systems include:

Launchd: introduced in Mac OS X v10.4

Runit

OpenRC: Gentoo Linux

Starting System Services

To start system services, you must manually run the daemon. To manually start a daemon, use:

# /usr/sbin/httpd -f /etc/httpd/httpd.conf

To start a daemon using a SYSV init script, use:

# /etc/init.d/httpd start

To start a daemon using the service/ command, use:

# service httpd start

The service name can differ on different distributions. To start a daemon using the OpenSUSE rc[COMMAND] command, use:

# rcapache2 start

To start a daemon using upstart, use:

# start apache

To start a daemon using systemd, use:

# systemctl start httpd.service

Stopping System Services

To stop system services, you must manually stop the daemon. To manually stop a daemon, use:

# kill 

To stop a daemon using a SYSV init script, use:

# /etc/init.d/httpd stop

To stop a daemon using the service command, use:

# service httpd stop

The service name can differ on different distributions. To start a daemon using the OpenSUSE rc[COMMAND] command, use:

# rcapache2 stop

To stop a daemon using upstart, use:

# stop apache

To stop a daemon using systemd, use:

# systemctl stop httpd.service

Enabling and Disabling System Services

System services must be enabled so they automatically start at boot time. To manually enable and disable a system by linking its SysV init script, use:

# ln -s /etc/init.d/httpd /etc/rc3.d/S85httpd
# rm /etc/rc3.d/S85httpd
# ln -s /etc/init.d/httpd /etc/rc3.d/K25httpd

To use the chkconfig helper script on CentOS6 or OpenSUSE to enable and disable a service, do:

# chkconfig httpd on
# chkconfig httpd off

To use the Ubuntu update-rc.d helper script to enable a service, do:

# update-rc.d apache2 enable 2345
# update-rc.d apache2 disable 2345

To enable or disable a service using systemd, use:

# systemctl enable httpd.service
# systemctl disable httpd.service

Transient System Services

Some services are not used enough to keep a daemon running full time. The xinet daemon was created to manage these transient daemons (Figure 1). xinet is started by using the system-specific init system. xinet listens on the proper port and, when a connection is made, it starts the managing daemon and passes off the connection.

Come back next week for the final blog in this series, to test your new knowledge with quizzes and lab exercises.

The Linux Foundation offers both certification tests and training, which you can read all about at Linux Foundation Training. You can become a Linux Foundation Certified Sysadmin, or a Linux Foundation Certified Engineer. In this series, you’ll get a look at our new Linux Foundation Certified Engineer prep course. The full LFCE course has 12 chapters.

Download the full sample chapter: Linux Networking Concepts and Review.