Linux TOP commands are sorted by memory usage and by CPU usage

Source: Internet
Author: User

Linux TOP commands are sorted by memory usage and by CPU usage P-process list in the order of CPU usage M-process list in the order of memory usage during system maintenance, you may need to check the CPU usage at any time and analyze the system status based on the corresponding information. In CentOS, you can use the top command to view CPU usage. After running the top Command, the CPU usage status will be displayed in full screen mode and in dialog mode-the top-based command can be used to control the display mode. The command to exit top is q (Press q once in top running ). Enter "top" in the command line to start top. The full-screen dialog mode of top can be divided into three parts: system information, command input, and process list. Part 1-system information column at the top: Line 1 (top): "14:55:59" indicates the current time of the system; "4 days," indicates the current operating time after the system is started; "1 user" is the user currently logged on to the system, more specifically, the number of terminals that log on to a user-the number of terminals that a user connects to multiple terminals in the system at the same time is considered as multiple users connecting to the system, the number of users here will also be the number of terminals; "load average" is the average value of the current system load, the following three values are the average number of processes one minute ago, five minutes ago, and 15 minutes ago. Generally, when this value exceeds the number of CPUs, the CPU is hard to load the processes in the current system. The second line (Tasks): "12 total" indicates the total number of processes in the current system; "1 running" indicates the number of processes in the current running state; "11 sleeping" indicates the number of processes in the waiting state; "0 stoped" indicates the number of stopped system processes; and "0 zombie" indicates the number of recovered processes; the third line (Cpus) indicates The current CPU usage. Row 4 (Mem) indicates the total memory usage, current usage, idle memory usage, and buffer memory usage. Row 5 (Swap ): indicates that the category is the same as the fourth row (Mem), but this shows the usage of Swap partition (Swap. In general, Swap partitions (Swap) are frequently used and are considered to be caused by insufficient physical memory. Part 2-Internal Command Prompt bar in the middle section: You can use the top internal command to control the display mode of processes during top running. The internal commands are as follows: s-change the screen update frequency l-close or enable the first line of top information in the first line t-close or enable the first part of the second line of Tasks and the third line of Cpus information m-close or enable the expression N of the first part of the fourth line Mem and the fifth line Swap information. In the order of PID size, the process list P is displayed. In the order of CPU usage, the Process List M is displayed. sequential process list of memory usage size h-show help n-set the number of processes displayed in the Process List q-exit tops-change screen update cycle part 3-process in the bottom list bar: the process list differentiated by PID is regularly updated based on the set screen update time. You can use the top internal command to control the display mode. In general, we maintain the server through remote monitoring, so that the local terminal of the server runs top in real time, which is one of the fast and convenient ways to monitor the server status locally on the server. Ubuntu Process Management Method ps display current process ps-l display details ps-u display relevant fields in user format description F Process status mark S Process status code UID process performer id ppid parent process parent process ID) the nice value of the PRI process execution priority (priority) NI process execution priority, negative value indicates the memory occupied by the SZ process with a higher priority. The address % CPU usage % MEM memory usage % VSZ occupied virtual memory size RSS occupied physical memory size START process START time kill Delete process kill pid Delete process of the specified pid kill-l view all available signals kill-9 pid force Delete process, the SIGKILL signal kill-15 pid is sent to force the process to be deleted, and the SIGTERM signal kill-HUP pid is sent to restart Deam On process free view memory usage status free-s 10 check memory usage every 10 seconds nice set execution priority,-20 ~ 19,19 the lowest sudo nice-2 vi sets the vi priority to-2 renice to modify the execution priority,-20 ~ 19,19 lowest top dynamic display process sort by "P" key by CPU usage time sort by "M" Key sort by memory usage sort by "T" Key sort by execution time sort by "u" key monitoring specific users press the K key to delete the process top-d 10 specify the Update Time lsof-p view the files opened by the process jobs command view background job ubuntu End Process Method 1 open Terminal 2, knock ps-ef to find the process number (that is, the PID column) 3. Press the kill PID (if the PID is 123456, then kill 123456). 4. When the local Ubuntu Linux system runs large software, or the server runs 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! Next we will introduce several methods to end processes under Ubuntu Linux! The safest way to kill a process is to 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: the Standard kill command can usually 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 # ps-ef | grep httpd of the process to be killed to end the process in the most elegant way # kill-l PID-l option to tell kill command 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. The TERM signal sends a TERM signal to the parent process, trying to kill it and its child process. # Kill-term ppid 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 a process. Sometimes, you only want to simply stop and restart the process. Run the following command: # kill-hup pid to shut down Linux's slow execution process and restart it 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-approved kill-s SIGKILL this powerful and dangerous Command forces the process to terminate suddenly at runtime, and the process cannot be self-cleaned 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.

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.