Linux daemon introduction and instance details, linux daemon details

Source: Internet
Author: User
Tags syslog

Linux daemon introduction and instance details, linux daemon details

Introduction to the Linux daemon and instance details

Introduction

Daemon is a special process running in the background. it is independent of the control terminal and periodically executes a task or waits for processing certain events. daemon is a very useful process. most Linux servers are implemented using daemon. for example, the Internet server inetd and the Web Server httpd. at the same time, the daemon completes many system tasks. for example, job planning process crond and printing process lpd.

The following are some common Daemon Processes in linux.

Amd: automatically installs NFS (Network File System) Guard Processes
Apmd: Advanced Power Management
Arpwatch: records logs and constructs an ethernet address and IP address pair database that is visible on the LAN interface.
Autofs: automatically installs the management process automount, which is related to NFS and relies on NIS.
Bootparamd: boot parameter server that provides information required for booting a diskless workstation on the LAN
Crond: scheduled tasks in Linux
Dhcpd: Start a DHCP (Dynamic IP Address Allocation) server.
Gated: Gateway route waiting process, using dynamic OSPF route selection Protocol
Httpd: WEB Server
Inetd: Core waiting program supporting multiple network services
Innd: Usenet News Server
Linuxconf: allows you to use a local WEB server as a user interface to configure machines.
Lpd: Print Server
Mars-nwe: the mars-nwe file and the printing server for Novell
Mcserv: Midnight command file server
Named: DNS Server
Netfs: Install NFS, Samba, and NetWare Network File Systems
Network: Activate the script program with configured network interfaces
Nfs: Enable the NFS service
Nscd: nscd (Name Switch Cache daemon) server, used for a support service of NIS. It caches user passwords and forms member relationships at a high speed.
Portmap: RPC portmap manager, similar to inetd, which manages RPC-based connections
Postgresql: An SQL Database Server
Routed: Route waiting process, using dynamic RIP route selection Protocol
Rstatd: A waiting program for other machines on the LAN to collect and provide system information
Ruserd: remote user location service, an RPC-based service that provides user information about a machine log recorded on the LAN.
Rwalld: activates the rpc. rwall service process. This is an RPC-based service that allows users to write messages to each terminal registered on the LAN machine.
Rwhod: activates the rwhod service process. It supports rwho and ruptime services of the LAN.
Sendmail: sendmail
Smb: Samba file sharing/printing service
Snmpd: process management in a local SIMPLE NETWORK
Squid: Activate the proxy server squid
Syslog: a script that enables syslog and klogd system logs to wait for processes during system boot.
Xfs: X Window server, which provides a font set for local and remote X Servers
Xntpd: Network Time Server
Ypbind: activates the ypbind service process for the NIS (Network Information System) client.
Yppasswdd: NIS Password Server
Ypserv: NIS master server
Gpm: Manage the mouse
Identd: AUTH service, similar to finger in providing user information

Key Points of daemon Programming

The programming of daemon is not complex. The complicated problem is that different versions of Unix have different implementation mechanisms, resulting in inconsistent programming rules of daemon in different Unix environments. the following describes the programming points of the daemon in Linux and provides detailed examples.

The programming rules of daemon in different Unix environments are inconsistent. fortunately, the programming principles of the daemon process are the same. The difference is that the specific implementation details are different. this principle is to satisfy the characteristics of the daemon. the main points of programming are as follows:


A daemon instance has two parts: the main program test. c and the initialization program init. c. the main program sends the log test to the/tmp directory every minute. log reports the running status. the init_daemon function in the initialization program is responsible for generating the daemon process. you can use the init_daemon function to generate your own daemon process.
1. init. c LIST
# Include <unistd. h> # include <signal. h> # include <sys/param. h> # include <sys/types. h> # include <sys/stat. h> void init_daemon (void) {int pid; int I; if (pid = fork () exit (0); // It is the parent process, stop the parent process else if (pid <0) exit (1); // fork failed, exit // is the first sub-process, and the background continues to execute setsid (); // The first sub-process becomes the new session leader and process leader, and is separated from the control terminal if (pid = fork () exit (0); // is the first sub-process, stop the first sub-process else if (pid <0) exit (1); // fork failed, exit // is the second sub-process, continue, the second sub-process is no longer the session leader for (I = 0; I <NOFILE; ++ I) // close the opened file descriptor close (I ); chdir ("/tmp"); // change the working directory to/tmp umask (0); // reset the file creation mask return ;}
2. test. c LIST
# Include <stdio. h> # include <time. h> extern void init_daemon (void); // Daemon initialization function main () {FILE * fp; time_t t; init_daemon (); // initialize to Daemon while (1) // test every minute. log reports the running status {sleep (60); // if (fp = fopen ("test. log "," a ")> = 0) {t = time (0); fprintf (fp," I'm here at % s \ n ", asctime (localtime (& t); fclose (fp );}}}


Error Message
If the linux daemon does not understand the problem, the problem is as follows:

Q1: There are many independent httpd, named, and sshd commands. Generally, service commands can operate on independent daemon. Their ports are always on and monitored for access.
Xinetd monitors services such as telnet, tftp, and rlogin. xinetd binds the service to the port, for example, tftp service port 69. In general, port 69 is disabled, once a user accesses port 69, the xinetd enables port 69, that is, the tftp service.
Some services can be opened independently or managed to xinetd. It depends on whether the services are commonly used. If they are often used, they are used independently. If they are not commonly used, they are xinetd, saving resources.

Q2: kill can be used to kill
In addition, linux cannot just "watch" The exercises. You 'd better find the answer to the above questions through your exercises.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.