When you’ve been working with Linux for some time one thing you’ll notice is the number of programs running that are called daemons. The name originates from Maxwell’s Demon which was a thought experiment that attempted to describe a being that existed in the background constantly sorting molecules. Maxwell’s Demon bore more of a resemblance to the daemons of Greek mythology who carried out their work with no particular affiliation towards good or evil, unlike the Christian demons of evil. Daemon was first used as a term by a group of MIT researchers to describe applications that run in the background on a system performing functions on the computer.
In modern Linux systems daemons are usually started automatically by the init process on bootup rather than by the user interactively. Their uses cover many processes from remote access through to web page serving. Without these daemons much of your Linux system wouldn’t function, so lets have a look at a number of the common daemons in use on servers:
sshd - the Secure Shell Daemon: this handles remote connections to the server using the Secure Shell protocol.
crond - the cron daemon: this manages the processes scheduled using cron.
httpd - the Apache web server daemon: this handles incoming requests for web pages from the server.
lighttpd - the lighttpd (pronounced ‘lighty’) web server daemon: this is an alternate web server to Apache.
named - the BIND nameserver daemon: this handles incoming DNS requests to the server.
ntpd - the network time protocol daemon: this handles requests from remote servers to synchronise their times to the server, and also keeps the server’s time accurate.
syslogd - the system logging daemon: this handles logging on the system of system messages.
mysqld - the MySQL daemon: this is the daemon for the popular open source relational database system.
postgres - the PostgreSQL daemon: this is the daemon for the PostgreSQL database system.
ftpd - the file transfer protocol daemon.
nfsd - the network file system daemon.
sendmail - the sendmail daemon: this program is an email server.
postfix - this is an alternative email server to sendmail.
There are some oddities in this, one key one being the ‘iptables firewall’ which runs as a kernel module (Kernel modules are code structures that can be loaded or unloaded into the kernel, which is the central software that runs the system)rather than its own independent daemon process. This is something that can often confuse a newbie when they are looking for an iptables process using ps.
Daemons are usually started and stopped using init scripts or service startup scripts.
For example, two ways of starting the ssh daemon are:
service sshd start
Similarly, they can be stopped by substituting the word ‘start’ for ‘stop’. Also, alternatively using the word ‘restart’ stops and then starts the daemon again. Some daemons’ scripts support the status command to provide additional information. Similarly the reload command may be supported to force the daemon to re-read its configuration file without restarting itself.
The fact that daemons run in the background means that there is no easy way to display information on how the daemons are running to the command line. As such these daemons generally log their output to logfiles which are usually found in the /var/log directory, allowing the systems administrator to gather information on how the daemons are running from reading through those files.
Something of note is that any daemons that are running will be using system resources even if they are receiving no incoming requests to do anything. Also, if a daemon is running and listening for a connection from the internet that you are not using, this may potentially pose a security issue to your server. In that respect it’s fairly important to make sure that you stop and disable any unneeded daemons from starting. This can easily be done by using the chkconfig utility.
An example of stopping sshd from starting follows:
chkconfig sshd off
To reverse the setting simply swap the word ‘off’ for ‘on’.
Daemons are quite important in the day-to-day running of your Linux based server, so understanding what you are using and why is also important and can help when troubleshooting any problems. So time spent getting to know them can be invaluable later.
VPS.net offers clients a highly adaptable and scalable solution to hosting needs and comes in several varieties of Operating System, including Linux. Check it out here.