- How to Find the List of Daemon Processes and Zombie Processes in Linux
- What is Zombie Process?
- Daemons?
- Foreground Processes
- Background Processes
- Listing Running Processes
- Full Usage of PS Command
- Stopping Processes
- Daemons
- Contents
- Typical functions of daemons
- List of service daemons for Linux and Unix-like systems
- How do I start / stop / restart daemons for the shell prompt?
- How do I see list of all running daemons?
- Linux Jargon Buster: What are Daemons in Linux?
- What is a Daemon in Linux?
- What Daemons are Running on Your Machine?
- Spawning Daemons
- Examples of Linux Daemons
- What is the origin of the word, daemon?
How to Find the List of Daemon Processes and Zombie Processes in Linux
This article will guide you to understand the Zombie process and Daemons, and also help us to find the process which is running in the background.
What is Zombie Process?
When a process ends the execution, then it will have an exit status to report to its master process. Because of that little bit of information, the process will remain in the OS process table as a zombie process, which indicates that it is not to be scheduled for future, but this process cannot be completely removed or the process ID will not be used until the exit has been determined and no longer needed.
When a child completes the process, the master process will receive a SIGCHLD signal to indicate that one of its child process has finished the executing; the parent process will typically call the wait() system status at this point. That status will provide the parent with the child’s process exit status, and will cause the child process to be reaped, or removed from the process table.
Daemons?
Linux is a multi-tasking operating system. Each program running at any time is called a process. Every running command starts with at least one new process and there are many numbers of system processes that are running.
Each process is identified by a number called Process ID (PID). Similar to files, each process has its owner and group, and the group and owner permissions are useful to identify which files and devices are related to those processes. Most processes also have their own parent process that started them.
Example: The shell is a process, and any command executed in the shell is a process which belongs to the shell parent process. The exception is a special process called init(8) which is the first process to start at booting time and which has a PID(Process ID) of 1.
Some programs are to be run with continuous user input and disconnected from the terminal. For example, a web server responds to web requests, instead of user input. Mail servers are another examples of this type application. These type of programs are also known as daemons.
Foreground Processes
Every process has to start running in the foreground. It gets its input from the keyboard and sends its output to the screen after the process.
You can see this happen with the ls command. If I want to list all the files in my current directory, I can use the following command –
This will show all the files in the current directory.
The process runs in the foreground and will direct the output to my screen, and if a command wants any input it waits for input.
While a program is running in foreground and taking so much time, we cannot run any other commands from the command prompt which can be available until the program finishes its processing.
Background Processes
A background process runs without being the interaction of users. If the background process requires any input, it waits.
The advantage of running a process in the background is that you can run other commands, and you are not supposed to wait until it completes to start another process.
The simplest way to start the background process is to add an ampersand (&) at the end of the command we execute.
The above will write the output to files file with all the files and directories which will take more time. So, for instance, ampersand (&) at the end of the line will run in the background as a process and the cursor will come to prompt waiting for another command.
The first line contains information about the background process about how many background process are running and the job number or process ID. We need to know the PID to manipulate it between background and foreground.
If you press the Enter now, we can see the following output
The first line tells you that the find command background process finishes successfully and waits for the other command.
Listing Running Processes
This command will list the own processes by running, the ps (process status) command.
The commonly used flags for ps is the -f, -f will display full information, which provides more information as shown below.
Full Usage of PS Command
Stopping Processes
A process can be stopped in several ways. Often, from a command line, by sending a CTRL + C keystroke – will exit the command. This works when the process is running in the foreground.
If a process is running in background mode, then first you would need to get its Job ID using the ps command and after that you can use kill command to kill the process as follows –
Here kill command would terminate ssh root@192.168.1.89. If a process ignores a regular kill, we can use kill -9 followed by the process ID as follows.
How can we see if there are zombie processes running on a system.
Run “ps aux” and look for a Z in the STAT column.
In the above example, the process with process ID 12196 is having status z, use the kill command to kill that process
After this article you are able to understand what is zombie process and daemons and how to find out it and how to stop it, also how to make a process in background.
Источник
Daemons
A daemon (also known as background processes) is a Linux or UNIX program that runs in the background. Almost all daemons have names that end with the letter «d«. For example, httpd the daemon that handles the Apache server, or, sshd which handles SSH remote access connections. Linux often start daemons at boot time. Shell scripts stored in /etc/init.d directory are used to start and stop daemons.
Contents
Typical functions of daemons
- Open network port (such as port 80) and respond to network requests.
- Monitor system such as hard disk health or RAID array.
- Run scheduled tasks such as cron.
List of service daemons for Linux and Unix-like systems
- amd — Auto Mount Daemon
- anacron — Executed delayed cron tasks at boot time
- apmd — Advanced Power Management Daemon
- atd — Runs jobs queued using the at tool
- autofs — Supports the automounter daemon allowing mount and unmount of devices on demand
- crond — The task scheduler daemon
- cupsd — CUPS printer daemon
- dhcpd — Dynamic Host Configuration Protocol and Internet Bootstrap Protocol Server
- ftpd — FTP Server Daemon
- gated — routing daemon that handles multiple routing protocols and replaces routed and egpup
- httpd — Web Server Daemon
- inetd — Internet Superserver Daemon
- imapd — An imap server daemon
- lpd — Line Printer Daemon
- memcached — In-memory distributed object caching daemon
- mountd — mount daemon
- mysql — Database server daemon
- named — A DNS server daemon
- nfsd — Network File Sharing Daemon
- nfslock — Used to start and stop nfs file locking services
- nmbd — Network Message Block Daemon
- ntpd — Network Time Protocol service daemon
- postfix — A mail transport agent used as a replacement for sendmail
- postgresql — Database server daemon
- routed — Manages routing tables
- rpcbind — Remote Procedure Call Bind Daemon
- sendmail — A mail transfer agent Daemon
- smbd — Samba (an SMB Server) Daemon
- smtpd — Simple Mail Transfer Protocol Daemon
- snmpd — Simple Network Management Protocol Daemon
- squid — A web page caching proxy server daemon
- sshd — Secure Shell Server Daemon
- syncd — Keeps the file systems synchronized with system memory
- syslogd — System logging daemon
- tcpd — Service wrapper restricts access to inetd based services through hosts.allow and hosts.deny
- telnetd — Telnet Server daemon
- vsftpd — Very Secure FTP Daemon
- webmin — Web based administration server daemon
- xinetd — Enhanced Internet Superserver Daemon
- xntd — Network Time Server Daemon
How do I start / stop / restart daemons for the shell prompt?
You need to use the service command as follows [1] [2] ::
In this example, start, stop, and restart httpd daemon:
How do I see list of all running daemons?
To see the status all installed daemons, enter:
Sample outputs from CentOS Linux development server:
Sample outputs from my Ubuntu Linux desktop systems:
Источник
Linux Jargon Buster: What are Daemons in Linux?
Last updated June 5, 2021 By Bill Dyer 29 Comments
Daemons work hard so you don’t have to.
Imagine that you are writing an article, Web page, or book, Your intent is to do just that – write. It’s rather nice not having to manually start printer and network services and then monitor them all day to make sure that they are working right.
We can thank daemons for that – they do that kind of work for us.
What is a Daemon in Linux?
A daemon (usually pronounced as: day-mon , but sometimes pronounced as to rhyme with diamond ) is a program with a unique purpose. They are utility programs that run silently in the background to monitor and take care of certain subsystems to ensure that the operating system runs properly. A printer daemon monitors and takes care of printing services. A network daemon monitors and maintains network communications, and so on.
Having gone over the pronunciation of daemon, I’ll add that, if you want to pronounce it as demon, I won’t complain.
For those people coming to Linux from the Windows world, daemons are known as services. For Mac users, the term, services, has a different use. The Mac’s operating system is really UNIX, so it uses daemons. The term, services is used, but only to label software found under the Services menu.
Daemons perform certain actions at predefined times or in response to certain events. There are many daemons that run on a Linux system, each specifically designed to watch over its own little piece of the system, and because they are not under the direct control of a user, they are effectively invisible, but essential. Because daemons do the bulk of their work in the background, they can appear a little mysterious and so, perhaps difficult to identify them and what they actually do.
What Daemons are Running on Your Machine?
To identify a daemon, look for a process that ends with the letter d. It’s a general Linux rule that the names of daemons end this way.
There are many ways to catch a glimpse of a running daemon. They can be seen in process listings through ps , top , or htop . These are useful programs in their own right – they have a specific purpose, but to see all of the daemons running on your machine, the pstree command will suit our discussion better.
The pstree command is a handy little utility that shows the processes currently running on your system and it show them in a tree diagram. Open up a terminal and type in this command:
You will see a complete listing of all of the processes that are running. You may not know what some of them are, or what they do, they are listed. The pstree output is a pretty good illustration as to what is going on with your machine. There’s a lot going on!
Looking at the screen shot, a few daemons can be seen here: udisksd, gvfsd, systemd, logind and some others.
Our process list was long enough to where the listing couldn’t fit in a single terminal window, but we can scroll up using the mouse or cursor keys:
Spawning Daemons
Again, a daemon is a process that runs in the background and is usually out of the control of the user. It is said that a daemon has no controlling terminal.
A process is a running program. At a particular instant of time, it can be either running, sleeping, or zombie (a process that completed its task, but waiting for its parent process to accept the return value).
In Linux, there are three types of processes: interactive, batch and daemon.
Interactive processes are those which are run by a user at the command line are called interactive processes.
Batch processes are processes that are not associated with the command line and are presented from a list of processes. Think of these as “groups of tasks”. These are best at times when the system usage is low. System backups, for example, are usually run at night since the daytime workers aren’t using the system. When I was a full-time system administrator, I often ran disk usage inventories, system behavior analysis scripts, and so on, at night.
Interactive processes and batch jobs are not daemons even though they can be run in the background and can do some monitoring work. They key is that these two types of processes involve human input through some sort of terminal control. Daemons do not need a person to start them up.
We know that a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user. When the system boot is complete, the system initialization process starts spawning (creating) daemons through a method called forking, eliminating the need for a terminal (this is what is meant by no controlling terminal).
I will not go into the full details of process forking, but hopefully, I can be just brief enough to show a little background information to describe what is done. While there are other methods to create processes, traditionally, in Linux, the way to create a process is through making a copy of an existing process in order to create a child process. An exec system call to start another program in then performed.
The term, fork isn’t arbitrary, by the way. It gets its name from the C programming language. One of the libraries that C uses, is called the standard library, containing methods to perform operating services. One of these methods, called fork, is dedicated to creating new processes. The process that initiates a fork is considered to be the parent process of the newly created child process.
The process that creates daemons is the initialization (called init ) process by forking its own process to create new ones. Done this way, the init process is the outright parent process.
There is another way to spawn a daemon and that is for another process to fork a child process and then die (a term often used in place of exit). When the parent dies, the child process becomes an orphan. When a child process is orphaned, it is adopted by the init process.
If you overhear discussions, or read online material, about daemons having “a parent process ID of 1,” this is why. Some daemons aren’t spawned at boot time, but are created later by another process which died, and init adopted it.
It is important that you do not confuse this with a zombie. Remember, a zombie is a child process that has finished its task and is waiting on the parent to accept the exit status.
Examples of Linux Daemons
Again, the most common way to identify a Linux daemon is to look for a service that ends with the letter d. Here are some examples of daemons that may be running on your system. You will be able to see that daemons are created to perform a specific set of tasks:
systemd – the main purpose of this daemon is to unify service configuration and behavior across Linux distributions.
rsyslogd – used to log system messages. This is a newer version of syslogd having several additional features. It supports logging on local systems as well as on remote systems.
udisksd – handles operations such as querying, mounting, unmounting, formatting, or detaching storage devices such as hard disks or USB thumb drives
logind – a tiny daemon that manages user logins and seats in various ways
httpd – the HTTP service manager. This is normally run with Web server software such as Apache.
sshd – Daemon responsible for managing the SSH service. This is used on virtually any server that accepts SSH connections.
ftpd – manages the FTP service – FTP or File Transfer Protocol is a commonly-used protocol for transferring files between computers; one act as a client, the other act as a server.
crond – the scheduler daemon for time-based actions such as software updates or system checks.
What is the origin of the word, daemon?
When I first started writing this article, I planned to only cover what a daemon is and leave it at that. I worked with UNIX before Linux appeared. Back then, I thought of a daemon as it was: a background process that performed system tasks. I really didn’t care how it got its name. With additional talk of other things, like zombies and orphans, I just figured that the creators of the operating system had a warped sense of humor (a lot like my own).
I always perform some research on every piece that I write and I was surprised to learn that apparently, a lot of other people did want to know how the word came to be and why.
The word has certainly generated a bit of curiosity and, after reading through several lively exchanges, I admit that I got curious too. Perform a search on the word’s meaning or etymology (the origin of words) and you’ll find several answers.
In the interest of contributing to the discussion, here’s my take on it.
The earliest form of the word, daemon, was spelled as daimon, a form of guardian angel – attendant spirits that helped form the character of people they assisted. Socrates claimed to have one that served him in a limited way, but correctly. Socrates’ daimon only told him when to keep his mouth shut. Socrates described his daimon during his trial in 399 BC, so the belief in daimons has been around for quite some time. Sometimes, the spelling of daimon is shown as daemon. Daimon and daemon, here, mean the same thing.
While a daemon is an attendant, a demon is an evil character from the Bible. The differences in spelling is intentional and was apparently decided upon in the 16th century. Daemons are the good guys, and demons are the bad ones.
The use of the word, daemon, in computing came about in 1963. Project MAC is shorthand for Project on Mathematics and Computation, and was created at the Massachusetts Institute of Technology. It was here that the word, daemon, came into common use to mean any system process that monitors other tasks and performs predetermined actions depending on their behavior, The word, daemon was named for Maxwell’s daemon.
Maxwell’s daemon is the result of a thought experiment. In 1871, James Clerk Maxwell imagined an intelligent and resourceful being that was able to observe and direct the travel of individual molecules in a specific direction. The purpose of the thought exercise was to show the possibility of contradicting the second law of thermodynamics.
I did see some comments that the word, daemon, was an acronym for Disk And Executive MONitor . The original users of the word, daemon, never used it for that purpose, so the acronym idea, I believe, is incorrect.
Lastly – to end this on a light note – there is the BSD mascot: a daemon that has the appearance of a demon. The BSD daemon was named after the software daemons, but gets is appearance from playing around with the word.
The daemon’s name is Beastie. I haven’t researched this fully (yet), but I did find one comment that states that Beastie comes from slurring the letters, BSD. Try it; I did. Say the letters as fast as you can and out comes a sound very much like beastie.
Beastie is often seen with a trident which is symbolic of a daemon’s forking of processes.
Like what you read? Please share it with others.
Источник