Today we will have a look at configuring services in Linux. For the purpose of this tutorial I will use Linux Mint 12 but the majority of the commands can be run on any Linux Distribution.
Seeing what services are running
To check what services are running on our system we need a package called chkconfig. Open up a terminal and type:
sudo apt-get install chkconfig
Once installed we need to check what is currently running (run as normal user) so type:
So how do we turn a service on and off?
The easiest way is to turn a service off for a particular run level and to do this we use the syntax: chkconfig -s ‘service name’ ‘run levels’.
So to take an example we will make the mysql service above start at runlevels 2 and 3 so type:
sudo chkconfig -s mysql 23
In the above screenshot mysql now starts at run levels 2 and 3
If you want to start and stop a service right now then you need to use init scripts. So this time we will stop the clamav-freshclam service so type:
sudo /etc/init.d/clamav-freshclam stop
sudo /etc/init.d/clamav-freshclam start to restart.
Upstart is the replacement for init scripts and as such some of the services have been re-written to work solely with upstart. If a particular service is now an upstart job then the syntax is:
service ‘service name’ start/stop
For example to turn the samba daemon on and off you would type:
sudo service samba start
sudo service samba stop
How do you configure a service to start at boot?
You can either use the runlevel method described above or for Upstart jobs use the following syntax:
update-rc.d ‘service name’ defaults
About the Author
Follow @Comtech247 on Twitter