In every basic system, there are a variety of basic processes for checking system services, communicating with the operating system, and so on. The performance of processes and systems is strongly related, therefore, a system manager should have a clear understanding of what is running in the current system, what resources are available, and so on, so that you can adjust the configuration, for example, prohibit unwanted processes, open the necessary monitoring procedures and adjust your kernel to optimize, Finally, get a best system for your own use. Ubuntu is a system designed for the masses, which also determines the popularity of its system settings, in other words, bloated. Many of the things we support in order to adapt to compatibility are not necessarily needed. Here, the author tries to explain some methods of optimizing the system by adjusting kernel parameters, shell parameters and specific application settings for reference. It's important to note that different Ubuntu systems have different startup scripts and have different running processes, which I can only explain on a 7.04 system basis. In fact, it is very important that you learn to track the process, only then you can be in different systems. In addition, if you want to more deeply adjust the system, then compile a system of their own is the most appropriate, this article does not involve such a deep thing. If you are interested in compiling your own Linux system, you can refer to this article and this article.
This article assumes that you have a little basic use of Linux, so a lot of things just talk about a conceptual outline, want to understand, there are many articles on the web. If you are a system master, basic can not see this article, you will feel very simple, if you are not even know ps,who-r novice, suggest you or put Google search some introductory articles, and personally use Linux more than a week, and then look back to this article. This article is to a large extent referred to the Ubuntu performance guides, long, so the two-page issue.
Introduction to basic knowledge understanding process Process
We have just mentioned the process a few times, so how do we understand this word? Broadly speaking, all that runs in a system, used to perform a variety of tasks, is a process that can be differentiated according to the specific execution of a task, for example, the system processes that are used to manage and maintain the operating system, and the user process that is used to handle the user's needs.
The process is not an independent concept, it is interactive, many processes provide services for other processes, or work together to accomplish a certain function. Some of these services are critical to the operation of the system, such as x-windows services. Most of the system processes are service-nature processes, while most user processes are application class processes. Applications, such as the FireFox you are currently using (or the other, most rated FF) are usually made up of one or more processes that meet the needs of your users. In general, service opening and closing is based on system requirements, and applications are turned on and off, based on user requirements.
The difference between what we're talking about here and what the service is is not obvious, for example, GNOME's desktop system consists of programs and processes that provide not only the services that other programs need, but also the needs of users. Gde can be called a collection of programs, processes, applications, and services that do not create any conflicts.
Of course, we still have to do a little bit of distinction, later to facilitate further explanation. Now unify, the process represents anything that can produce a running process marker, and a program represents an executable that can produce a process. Users can use the application directly, while the operating system uses the service.
Process Basic Operations
The only thing that can consume your resources on your machine is the running process. If you find that your system is suddenly slow and running abnormally, there are usually only two possibilities, one is that some processes are running abnormally, and the other is that some processes consume more resources than you have.
Of course, want to see what is running on your machine is actually very simple, using ps-aux or TOP command can be, these things a lot of information, I do not say more, it is not a man top or PS bar. Of course, the most convenient for beginners is to use the graphical interface of the System Monitor, as shown in the figure:
(Click to zoom)
All the information is in sight. Note that in System Monitor, you can see not only the process running, but also the disk usage, CPU usage, and much more valuable information that is likely to be used in the next section.
OK, now we know how to determine what process is abnormal if the system is abnormal. But what should we do next? Whether the command line or graphical interface display, you can see that each process has its own ID, that is, PID. They are the handle of the process, not the actual process. What's the difference? For a process with multithreading, you can have all threads have the same handle, or you can have one handle for each thread. Too professional? Well, in layman's terms, this is equivalent to ... Process ID, we pass it to mark the process. This thing in Ubuntu by default can have 32,768 different PID, each has a new process, assign a current unused PID to it.
Well, let's find the damn culprit who makes our system slow, look at its PID, and then close it with the kill PID command. Wait, are you sure this process is affecting your system? Are you sure it's not wrong to kill the good guys? Well, in fact, you can use the Kill-stop PID command to suspend a process, to see if we do not have it, our system is normal. If you find miscarriage, it doesn't matter, Kill-cont PID allows the process to continue to work.
In addition to the direct use of kill PID, we have a further kill process approach. Kill PID is just a term signal, then the process can capture the signal, start releasing resources, close the program, this is not done in a flash, so before you close the program, you can end the open file and complete the task you are doing. But this leads to a problem, if the process is working and cannot be interrupted, then the process can ignore the sigterm signal, and what if the process loses its response? Don't worry, we can try the Kill-1 PID command, which sends a hang up signal, meaning "abort signal", which tells the process that the terminal has been killed. But the signal is also only intercepted by a well-run process. Assuming neither of these approaches can end the process, you can only use the kill-9 PID. This command sends a true kill signal, and the process is not negligible for this signal. This is a "I do not care what you are doing, immediately stop" signal, that is, the process is immediately terminated, do not implement cleanup operations.
Signals are used to communicate with daemons and processes. Any active task is a process, and the daemon is a background service that waits to respond to certain events or to perform tasks on a scheduled basis. A program must have a signal handler built in it to capture and respond to signals. The Signal Reference Guide in Linux explains the various signals and the uses of these signals. Commonly used signals in addition to the above, there are int,chld and so on.