Improve ubuntu system performance by yourself

Source: Internet
Author: User
Article Title: improve the performance of the ubuntu system by yourself. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Every basic system contains various basic processes for checking system services and communicating with the operating system. Processes have a lot to do with the performance of the system. Therefore, a system administrator should be clear about what is running in the current system and what resources are available, you can adjust the configuration. For example, you can disable unnecessary processes, open necessary monitoring programs, adjust your kernel to optimization, and finally get the best system that suits you best. Ubuntu is a system designed for the public, which determines the popularization of its system settings. In other words, it is bloated. In order to adapt to compatibility, we do not need many things. Here, I try to explain some methods to optimize the system by adjusting kernel parameters, shell parameters, and specific application settings for your reference. It should be noted that different ubuntu systems have different startup scripts and different running processes. Here I can only explain them on the basis of the 7.04 system. In fact, it is very important to learn how to track and view processes. Only in this way can you be able to perform well in different systems. In addition, if you want to further adjust the system, it is most appropriate to compile your own system. This article does not involve such in-depth things.

This article assumes that you have a little basic knowledge of linux, so many things are just a conceptual outline. If you want to learn more, there are many articles on the Internet. If you are a master of the system, you don't need to read this article. You will think it is very simple. If you are a beginner who doesn't even know ps or who-r, we recommend that you search for some introductory articles on google and use linux for more than a week. Let's look back at this article. This article references Ubuntu Performance Guides for a long time, so it is published on two pages.

Basic knowledge
Understanding processes
Process Overview

How can we understand the process just a few times? Broadly speaking, all running tasks in the system are processes, but they can be differentiated based on the specific execution tasks. For example, system processes are used to manage and maintain the operating system, while user processes are used to handle user needs.

A process is not an independent concept. It interacts with each other. Many processes provide services for other processes or work together to complete a function. Some of these services are critical to system operations, such as the X-Windows service. The vast majority of system processes are service-oriented processes, while the vast majority of user processes are application-type processes. Applications, such as FireFox (or others) that you are currently using, are generally composed of one or more processes that meet your needs. In general, Service Activation and shutdown are based on system requirements, while application activation and shutdown are based on user needs.

The process we mentioned above is actually not very obvious. For example, Gnome's desktop system is composed of various programs and processes, they not only provide services required by other programs, but also support user needs. GDE can be called a collection of programs, processes, applications, and services without any conflict.

Of course, we still need to make a distinction to facilitate further explanation later. Now let's unify the process. The process indicates anything that can generate the running process identifier, and the program indicates the executable file that can generate the process. Users can directly use the application, but the operating system uses the service.
Basic Process operations

On your machine, the only thing that can consume your resources is a running process. If you find that your system suddenly slows down and runs abnormally, there are usually only two possibilities. One is that some processes run abnormally, another is that some processes consume more resources than you own.

Of course, it is very easy to see what is running on your machine. Just use the ps-aux or top command. There are a lot of materials for this stuff, so I won't say much about it, it cannot be man top or man ps. Of course, the most convenient way for beginners is to use the system monitor on the GUI,

Screeshot (click to zoom)

All information is visible. Note: In the system monitor, you can not only view the running status of processes, but also view the disk usage, CPU usage, and many other valuable information, which may be used in the following sections.

OK. Now we know how to determine what process is abnormal if the system is abnormal. But what should we do next? Whether it is a command line or graphic interface display, you can see that each process has its own ID, that is, PID. They are all process handles, rather than representing real processes. What is the difference? For a process with multiple threads, all threads can have the same handle, or each thread can have one handle. Too professional? Well, in general, this is equivalent ...... Process ID card. We use it to mark the process. This item can have 32768 different PIDs by default in ubuntu. Each new process allocates an unused PID to it.

Okay, let's find the damn culprit that slows down our system, look at its PID, and use the kill PID command to close it. Are you sure this process affects your system? Are you sure you are not mistaken for killing good people? Well, you can use the kill-stop PID command to pause a process and check whether our system is normal without it. If an incorrect case is found, it does not matter. kill-cont PID can allow the process to continue working.

In addition to directly using the kill PID, we also have a further approach to kill the process. Kill PID is just a TERM signal, and then the process can capture this signal, start to release resources, close the program, this is not done at once, so before closing the program, you can end opened files and complete ongoing tasks. But this leads to a problem. If the process is running and cannot be interrupted, the process can ignore this SIGTERM signal and what if the process loses response? Don't worry, we can also try the kill-1 PID command, which sends the hang up signal, meaning "stop signal", which tells the process that the terminal has been killed. However, this signal is only blocked by running processes. If neither of these methods can end the process, you can only use the kill-9 PID. This command sends a real kill signal, which cannot be ignored by the process. This is a signal that "no matter what you are doing, stop immediately". That is to say, the process is terminated immediately without cleaning.

Signals are used to communicate with the daemon and process. Any active task is a process, and the daemon is a background service waiting to respond to certain events or execute tasks according to the schedule. A program must have a signal processing program built in it for capturing and responding to signals. The signal Reference Guide in LINUX explains various signals and their usage. Common signals include INT, CHLD, and so on.
Advanced Process operations

Of course, it is not enough to understand the above knowledge. Next, I will introduce more about processes.

First, we need to know that not all processes will be dynamically assigned a PID. At least two processes will not, that is, kernel and init. The PID of the kernel process is 0, always 0, and you cannot see it from ps and top commands. Of course, you cannot use the kill command to terminate it. The init process is the primary parent process. What does it mean? Each process requires a parent process to monitor it. The role of the parent process is to accept the returned values and Status values of the child process. If the parent process of any process is terminated, init will become its parent process. The pid of the init process is fixed to 1. Theoretically, you can terminate it, but never try to do so because it is used to clear the dead process. Once it is killed, the system will eventually crash.

Apart from them, you should not kill some processes, including Zombies,/O Bound-A and Interception. In fact, we seldom release these processes, and ordinary users do not need to access them. Therefore, I will not explain their usage in detail here. Interested friends can google themselves.

Other processes can try to kill any exceptions while ensuring that the system does not crash. However, you must know that the kill command only works once. That is to say, if, I mean, if the process is restarted after it is killed, you have to run kill again, so that the loop is like this. Of course, at this time, you can't continue to kill it with it. It is the right way to track and view the root cause of its self-startup. Do you think this is too troublesome? Well, there is another way to be lazy: Look at the name of the process and use kill name to block it. I know that the kill-9-1 command is introduced in many places, but you need to know that this command will kill all your processes, including interface processes and terminals. And if you have the root permission ...... It will even kill all system applications, and then your system will crash. Therefore, using this command, you might as well press your restart button, which is more worry-free ......

[1] [2] [3] [4] [5] [6] Next page

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.