Manage installed services using linux service command

Managing Installed services – Linux service command & chkconfig

Services are programs (called Daemons) that once started fun continuously in the background and are ready for input or monitor changes in your computer and respond to them. For example the apache server has a daemon called httpd [ the d for daemon] that – on port 80 on your computer and when it receives a request for a page it sends the – data back to the client machine.

Many services are required to run all the time however many can be safely turned off for both. Security reasons as running unnecessary services opens more doors into your computer, but – for performance reasons.

It may not make much difference but you computer should boot slightly faster with less services it has for start on boot.

One of the technologies in every Linux administrator’s toolbox to improve security of a box is to turn off unused services.

 

Chkconfig and Linux service command

There are two commands used to control services:

Service: This controls the starting and stopping of services during a session, these setting are not saved if you start Apache this way but it is not ser to start on boot using the above method then it will continue to run but on next boot will not start automatically.

Chkconfig: This controls which services are set to start on boot, by their nature these setting are saved and are applied at next boot. Changing these settings will not start the service immediately:

It will just flag them to be started from the next boot.

The command use for maintaining a service is

#service <name of the service> status                  —             To check the status of the service

#service <name of the service> start                     —             To start the service

#service <name of the service> stop                      —             To stop a service

#service <name of the service> reload                 —             To reload the service without stop

#service <name of the service> restart                 —             To restart the service (stop – start)

#service  –status-all                                                      —             To see all the service status

 

The command use for service availability is

#chkconfig  –list                                                               —             To check the availability of service

#chkconfig <service> on                                              —             To make the service available after restart

#chkconfig <service> off                                             —             To make the service unavailable after restart

 

Examples :-

Check the status of ftp service “vsftpd”

To check the status of the above service use Linux service command

#service vsftpd status

 

Start the ftp services

To start the ftp service, the command is

#service vsftpd start

 

Reload the ftp services, may be required after doing some change in config file.

To reload the service, the Linux service command is

#service vsftpd reload

 

For restart the ftp or any service, required when reload does not work

To restart the ftp services, the command will be

#service vsftpd restart

 

Use of chkconfig Command to check the status of the all service availability.

To check the status of all serice availability, use

#checkconfig –list

 

Check the status of a particular service, say “vsftpd”Note: Where 0 1 2 3 4 5 6 are the run levels in Linux, The output shows that on which run level the service is available even after reboot.

To check the status of a vsftpd service, the command is

#chkconfig  — list <name of the service>

#chkconfig  — list vsftpd

 

Make the service availabile on for vsftpd.

To make the service availability on for vsftpd service,

#chkconfig vsftpd on

 

 

Make the service availability off for vsftpd.

To make the service availability off for vsftpd service,

#chkconfig vsftpd off

 

 

Make the service vsftpd availability on only on runlevel 5

To make the service availability on, on a particular runlevel, the syntax is

#chkconfig  – – level <1-6> <service> <on/off>

#chkconfig  – – level  5 vsftpd on

 

The same procedure can be used for making service unavailable in a particular run level.

 

Leave a Reply

Your email address will not be published. Required fields are marked *