Ubuntu – What are the differences between regular processes and services

servicesterminology

What are the differences between regular processes (like firefox, gimp, skype, etc.) and services (httpd, mysqld, etc.)? Obviously, services are different in their function, but I'm really wondering what's going on under the hood at the OS level? Are they treated in any different way?

Best Answer

Under the hood, services are ordinary processes. What sets them apart is what they do and how they are started (but it's not a hard-and-fast definition). Services typically don't have a user interface, and are typically started when the system boots and run in the background, listening to requests coming from other programs or through the network. Such processes are called daemons in the unix world.

There's a more general definition of service that's more conceptual: a service is a feature that your computer provides. This definition roughly matches what is managed by the service command. Many services are provided by daemons, but that's not always the case. For example the gdm service (the default login manager) is provided by a process that's not really a daemon (it has a user interface for you to type your password). Services like console-setup, mountall or networking (to take examples from /etc/init) aren't provided by continuously running processes, but are enabled and disabled by running some state-changing commands.

Another somewhat related concept is that of servers. A server is a program that listens to connections from other programs. (The connections might come through the network or by various local communication means.) Many servers are daemons, but a short-lived program can be a server and won't be considered a daemon; a program with a user interface also won't be considered a daemon. For example, the Emacs editor can run a server that listens to external requests to open files (i.e. running emacsclient myfile opens a file in a running instance of Emacs by contacting its associated emascsserver process); Emacs can start in daemon mode, meaning that the server is started but no GUI (a window will be opened when you open a file). By extension, a server computer is a computer whose main purpose is to run server programs.