Learning notes for common commands of Ubuntu processes (view termination optimization)

Source: Internet
Author: User
Tags memory usage sort cpu usage

Common process commands

Ps-a displays information about all processes on the current terminal.

Ps-u is displayed in user format

Ps-x displays the processes running in the background

Ps-aux full view

Sudo kill process number to terminate the process

Kill-9 process no. Terminates the process, with a higher intensity

Killall process number can terminate sub-processes related to the process

Top monitors memory and processes

Top-d 5 monitors memory and processes, refresh once every 5 seconds

Related fields

F process status flag
S process status code
UID process executor ID
PPID parent process ID (parent process ID)
Priority)
Nice value of the NI process execution priority. A negative value indicates a higher priority.
Memory occupied by SZ process
Address of the WCHAN process or system call wait time
% CPU usage percentage
% MEM memory usage percentage
Vmemory occupied by VSZ
Physical memory used by RSS
START process START time


Kill process deletion
Kill the pid to delete the process of the specified pid
Kill-l view all signals available for transmission
Kill-9 the pid forces the process to be deleted and transmits the SIGKILL signal.
Kill-15 the pid forces the process to be deleted and transmits the SIGTERM signal.
Kill-HUP pid restart Deamon process


Free View memory usage status
Free-s 10 check memory usage every 10 seconds
Nice sets the execution priority,-20 ~ 19,19 minimum
Sudo nice-2 vi sets the vi priority to-2
Renice modify execution priority,-20 ~ 19,19 minimum


Top dynamically display processes
Sort by "P" key by CPU usage time
Sort by "M" key by memory usage
Sort by the "T" key by the execution time
Press "u" to monitor specific users
Press K to delete the process.
Top-d 10 specifies the update time
Lsof-p: View files opened by the process
Jobs command to view background jobs


End the unresponsive process

1. Open a terminal (what is a terminal? Let's take a look at Ubuntu's help, which is the question mark on the right of the Firefox icon)
2. KnockPs-efThe process ID (that isPIDThat column)
3. KnockKill PID(If PID is 123456Killed 123456)
4. OK
 
Bytes --------------------------------------------------------------------------------------------------------------

What if I want to use the GUI and mouse? It's also easier:
Method 1:
1. Open the built-inSystem Monitor. In the system menu bar:
2. You are familiar with it.Windows Task ManagerAlmost one thing. With the mouse, everyone on Earth will use it...
3. ClickCtrl + alt + deleteStart? You just need to set it up and find the shortcut key setting tool.
Make the appropriate settings. ctrl + alt + delete has been used. We can use another shortcut key, such as alt + f3, to replace the default one, set our system monitor to ctrl + alt + delete. Use the commandGnome-system-monitor. In the future, it will be consistent with the usage habits of windows.
 
 
Method 2:
Recently, IThis articleThe htop software is very powerful ~
1. Install htop:Sudo apt-get install htop
2. Application ---> System tool -----> Htop, open it ~
3. It is much more powerful than top. Here we can see the system information, which can be sorted by cpu and memory usage resources. Like windows, we select a process, you can directly Press F9 or useClick the kill button in the blue background on the right., Similar to dos, huh, huh, so you canIt's easy to end a process..

Note: You can use the mouse to sort the text in the PID column. You can also use the mouse in the bottom column.
Tree to view the process hierarchy

Bytes ----------------------------------------------------------------------------------------------------------------------------
 
 
Below is an advanced tutorial from this article http://www.bo128.cn/index.php? Aid = 98 (cannot be accessed )~~~~ ·

When running large software in the local Ubuntu Linux system or after the server is running for a long time, some software with design defects may lead to false positives! What should we do after the program is suspended? In fact, this problem is simple and simple. It's okay to end the process directly! Just like what we do in Windows! The following describes how to end processes in Ubuntu Linux!

The safest way to kill processes

The safest way to kill a process is to simply use the kill command without a modifier or a flag.

First, use the ps-ef command to determine the PID of the process to be killed, and then enter the following command:
 
# Kill-pid

Note: Standard kill commands can achieve the goal. Terminate the problematic process and release the process resources to the system. However, if a child process is started and only the parent process is killed, the child process is still running and consumes resources. To prevent these so-called "zombie processes", ensure that all child processes are killed before the parent process is killed.

You can also use the following command to determine the PID or PPID of the process to be killed

# Ps-ef | grep httpd

End the process in the most elegant way

# Kill-l PID

The-l option tells the kill command to end the process as if the user who started the process had logged out. When this option is used, the kill Command also tries to kill the left child process. But this command is not always successful-you may still need to manually kill the child process and then kill the parent process.

TERM signal

Send a TERM signal to the parent process, trying to kill it and its child process.
 
# Kill-TERM PPID

Killall command

Killall command to kill all processes in the same process Group. It allows you to specify the name of the process to be terminated, rather than the PID.
 
# Killall httpd

Stop and restart processes

Sometimes you only want to simply stop and restart the process. As follows:
 
# Kill-HUP PID

This command causes Linux to shut down the slow execution process and then restart immediately. This command is convenient when you configure the application. You can execute this command when you need to restart the process after modifying the configuration file.

Kill-9 PID

Agreed kill-s SIGKILL

This powerful and dangerous command forces the process to terminate suddenly at run time, and the process cannot be cleaned up after it ends. The hazard is that the system resources cannot be released normally. It is generally not recommended unless other methods are ineffective.

When using this command, you must use ps-ef to confirm that no zombie process is left. Only the parent process can be terminated to eliminate zombie processes. If the Zombie process is adopted by init, the problem will be serious. Killing the init process means shutting down the system.

If there is a zombie process in the system, and its parent process is init, and the Zombie process occupies a large amount of system resources, you need to restart the machine at some time to clear the process.

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.