System ProgrammingLearn about Managing Services in Red Hat Linux Part 1

Learn about Managing Services in Red Hat Linux Part 1

One of the most famous terms in the world of computers is the Client-Server Model. In this model, a computer could have one of two roles: either a client or a server (actually, it could be both). A server is a computer that runs one or more programs that serve other computers (clients). These programs usually run as background processes, and start automatically when the server boots up. These programs are called Services. Managing Services will be the subject of today’s article. I hope you find this topic useful.

The ISET Approach
The recommended approach to manage Red Hat Linux Services is called ISET. ISET is short for Install, Start, Enable, and Test.

Install: the package that contains the service.
Start: the service, and make sure it starts without errors or problems.
Enable: the service, to start automatically after reboots.
Test: the services to verify it is working as expected.

The Installation step has been covered with details in two articles: Software Package Management (1) and (2). So, let’s move the focus to the next step in the approach: Starting the Service.

The service Command
This command is used to start, stop, reload, or restart a service. It could also print the status of one or all services.

Syntax

service SCRIPT COMMAND

Where the list of available commands depends on the invoked script.

Examples

  • To print the status of the httpd service:
    httpd-service
  • To start the ntpd service:
    ntpd-service
  • Now, check the status of the ntpd service after being started:
    status-of-the-ntpd
  • You have modified the configuration file(s) for a service. For the changes to take effect, you need to restart the service:
    restart-the-service
  • To print the status of all services:
service --status-all

Enabling Services
Enabling a service means to configure it to start automatically when the server boots up to a specific runlevel. A runlevel (as defined by the Red Hat 6 Deployment Guide) is a state or mode, defined by services that are meant to be run when this runlevel is selected.

Red Hat defines 7 runlevels, ranging from 0 to 7:

Runlevel

Description

0

Halt. Taking the system to this runlevel halts (powers off) the system.

1

Single-user mode. This mode is used for recovering a forgotten root password.

2

Not used. The administrator can customize it according to his preference.

3

Multi-user mode with command-line interface.

4

Not used. The administrator can customize it according to his preference.

5

X11 Multi-user mode with graphical user interface.

6

Reboots the system.

To display the current runlevel, use the runlevel command:
runlevel
The output shows that the system is running in multi-user mode with GUI interface.

Moving Between Runlevels
To take your system to another runlevel, use the init command:

Syntax
init RUNLEVEL

Example
To take your Red Hat server to the multi-user mode with command-line interface:
init 3

To initialize it in GUI mode again:
init 5
init-5

Setting the Default Runlevel
You can set the default runlevel that your Red Hat Linux box will boot into in the /etc/inittab file. In the mentioned file, locate the line:
default-runlevel
This system is configured to boot to the X11 multi-user mode (runlevel 5). To change this setting to start in runlevel 3, edit the line and replace 5 with 3, then save and exit the file. When you reboot the system, it will boot up automatically to the multi-user mode with CLI.

The chkconfig Command
Among other uses, the chkconfig command is used to:

  • List the current startup information for services.
  • Change the startup information for services.
  • Checking the startup state of a particular service.

Syntax
chkconfig SERVICE on|off
chkconfig SERVICE –list
chkconfig –list

Examples

    • To enable the httpd service (configure it to start automatically when the server starts up):
chkconfig httpd on
  • chkconfig-httpd
    To check the startup setting of the httpd service:
    startup-setting
  • To disable the ntpd service (prevent it from starting when the system boots)
    ntpd-service
  • To display the startup status of all services on this system:
    startup-status

Summary

  • To start, stop, and restart services, use the service command with the suitable sub-command.
  • A runlevel is a state or mode, defined by services that are meant to be run when this runlevel is selected.
  • To move from one runlevel to another, use the init command with the new runlevel as a numeric argument.
  • The chkconfig command enables, disables, and displays the startup status of services.

That was part one. See you in part two.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exclusive content

- Advertisement -

Latest article

21,501FansLike
4,106FollowersFollow
106,000SubscribersSubscribe

More article

- Advertisement -