chkconfig Cheat Sheet

chkconfig Cheat Sheet

Get Social!

Linux penguinControlling startup services in Linux distributions such as Red Hat Enterprise Linux (RHEL), CentOS and Oracle Enterprise Linux (OEL) can be done using a Gnome GUI or a command line utility. The command line utility is called chkconfig and can list existing, add new or remove services from the operating systems startup list.

As Linux operating systems have multiple states, or runlevels, you need to make sure you add any new services to the correct runlevels. For example, you would not want to start a web service application before starting networking. See my post on runlevels.

What services are available for startup?

Use the –list switch to see your existing services and when they should be running.

An example output is below. This shows all of the machine runlevels and what the state of the service will be.

In this example, there are three services available. netconsole is not available at any runlevels and is therefore never started automatically, network is available only in runlevel 3 and modules_dep is available in runlevel 2 and runlevel 3.

You could also use the example below to detail the runlevels of a single service only.

Add a new service with chkconfig

Adding a new service is  easily done with the below command. The below example shows the service network being enabled to start at the next machine boot.

Use the –level switch to enable the service at specific runlevels. Use the below example to enable the service at runlevel 3.

Remove a service with chkconfig

Removing an existing service is done with the below command. The below example shows the service network being disabled from automatic start.

Use the –level switch to remove the service from specific runlevels. Use the below example to disable the service at runlevel 3.

Start a service

Starting a service is done using the command service followed by the service name and the command to start the service.

Stop a service

Use the stop keyword with service to stop a service.

Check the status of a service

Each service has a status, usually running or not running. Some services, such as network, may have a different output and output more information on the service.

 

Let me know in the comments if you think anything is missing.


Related posts:


1 Comment

Eli

26-Oct-2014 at 9:27 pm

Your add/remove section with on/off isn’t for adding/removing, it’s for configuring the runlevel on/off of the service.

How do we actually “add” a service? What do we need to do so this command will work: “chkconfig –add NAME”

Leave a Reply

Visit our advertisers

Search

Quick Poll

Which type of virtualisation do you use?
  • Add your answer

Visit our advertisers