Memory and Process Management

Source: Internet
Author: User
Tags pkill

This section of the content is a little miscellaneous, you can only manually enter the

The 1.uname command is used to print information about the current system (kernel version number, hardware architecture, host name, operating system type, and so on).

Uname-a Show All information

2.cat/etc/redhat-release

View current system version

3.free-m/G

View memory usage (in megabytes and gigabytes)

The information displayed is from/proc/meminfo

The Free command provides a more concise view of system memory usage relative to top:

# free
Total used free shared buffers Cached
mem:255988 231704 24284 0 6432 139292
-/+ buffers/cache:85980 (USED2) 170008 (free2)
swap:746980 0 746980

Mem: Indicates physical memory statistics

-/+ buffers/cached: Cache statistics representing physical memory

Swap: Indicates the usage of the swap partition on the hard disk, we don't care about it here.

Total physical memory of the system: 255988Kb (256M), but the actual memory currently available to the system is not the 24284Kb of the first line of the free tag, it represents only unallocated memory.

Total: Indicates the amount of physical memory.
Used: Represents the amount that the total is allocated to the cache (including buffers and cache), but may not be actually used in some of the caches.
Free: Memory that has not been allocated.
GKFX: Shared memory, general system will not be used, nor discussed here.
Buffers: The number of buffers that are allocated but not used by the system.
Cached: The number of caches that the system allocates but has not been used. The difference between buffer and cache is shown later.

USED2: The total amount of buffers and caches actually used, as well as the amount of memory actually used.
Free2: The sum of unused buffers with the cache and unallocated memory, which is the current actual memory available to the system.

You can sort out the following equation:

Total = used + Free
Total = Used2 + free2
Used = buffers + cached + Used2
Free2 = buffers + cached + Free


the difference between buffer and cache

A buffer is something that have yet to being "written" to disk.
A cache is something that have been "read" from the disk and stored for later use.

2. Monitoring of processes in the system-PS (see Linux System Management P363)
1) Mastering the definition of process: a process is a dynamic execution of a program.
2) Master the definition of daemons: daemons are some processes that run in the background and provide system services.
3) Master the definition of parent and child processes: When a process creates another process, the 1th process is called the parent process of the new process, and the new process is called a child process.
4) Mastering the functions of the PS command: used to display the status of the current process.
Ps–aux Show all the user-related complete information
Monitoring of processes in the system pstree, kill

Centos7 default no Pstree, requires yum-y install Psmisc
1) Master the function of the Pstree command: Display the program in a tree-like chart.
2) Use examples of mastering Pstree commands:
For example: List the process state tree commands for a PID 4729 process: Pstree 4729

Format: Pstree

Displays the process in a tree view, showing only the name of the process, and the same process is displayed in the merge.

Format: pstree-p

Displays the process in a tree view, and also shows the process PID.

Format: Pstree <pid>

Format: Pstree-p <pid>

A tree view shows the process PID for the process of <pid> and descendant processes, and if there is a-p parameter, the PID of each process is displayed.


3) Master the function of the KILL command: Send a signal to one or more processes. The default send termination signal.
4) Flexible application KILL command to terminate process
Example: a command to terminate a process with a PID of 3852: Kill 3852
5) Flexible Application kill-9 command kill process
Example: A command to kill a process with PID 3906: kill-9 3906
3. Mastering the function of the pgrep command: Find a process by name or other property
For example, the command to find a process named Firefox is: Pgrep Firefox
4. Mastering the function of the Pkill command: Send a signal to the process by name or other attribute
For example, the command to kill a process named Firefox is: Pkill Firefox
5. After-school assignments (spents 30 minutes)
1) Real-time dynamic monitoring System Status
2) exit the previous step
3) Turn on the top process
4) Use the PS command to view the top command's PID and kill
5) View process tree for process with PID 2
6) Open Firefox browser
7) Look for a process named Firefox
8) Kill the process called Firefox

Introduction

The top command is a common performance analysis tool under Linux that shows the resource usage of individual processes in the system in real time, similar to the Task Manager for Windows.

Top display system current process and other conditions, is a dynamic display process, that is, you can continue to refresh the current state through the user keys. If the command is executed in the foreground, it will monopolize the foreground until the user terminates the program. More accurately, the top command provides real-time status monitoring of the system's processor. It will display the most "sensitive" CPU in the system Task List. This command can be used by CPU. Memory usage and execution time to sort tasks, and many of the features of the command can be set through interactive commands or in personal customization files.

Here is a detailed description of how it is used.

parameter meaning
top-01:06:48 up  1:22,  1 user,  load average:0.06, 0.60, 0.48
Tasks: Total , 1 running, sleeping, 0 stopped, 0 zombie
Cpu (s): 0.3% us, 1.0% sy, 0.0% ni, 98.7% ID, 0.0% wa, 0.0% hi, 0.0% si
Mem: 191272k Total, 173656k used, 17616k free, 22052k buffers
Swap: 192772k Total, 0k used, 192772k free, 123988k Cached

PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
1379 root 0 7976 2456 1980 S 0.7 1.3 0:11.03 sshd
14704 root 0 2128 980 796 R 0.7 0.5 0:02.72 Top
1 root 0 1992 632 544 S 0.0 0.3 0:00.90 Init
2 root 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0


The first five elements of the statistical information area are the statistical information of the whole system. The first line is the task queue information, with the execution result of the uptime command. The contents are as follows:

01:06:48    Current Time
Up 1:22 system run time, format last: minutes
1 user Current number of users logged on
Load average:0.06, 0.60, 0.48 system payload, which is the average length of the task queue. The three values were 1 minutes, 5 minutes, and 15 minutes ago to the present average.

The second to third behavior process and CPU information. When there are multiple CPUs, the content may be more than two lines. The contents are as follows:

Total process count running number of processes running sleeping number of processes stopped stopped number of processes zombie Zombie process CPU (s): 0.3% US user space consumes CPU percent 1.0% SY core space consumes CPU percent 0.0% N I user process space has changed the priority of the process to occupy CPU percentage 98.7% ID idle CPU percent 0.0% WA waiting for input output CPU time percentage 0.0%hi: Hardware CPU interrupt consumption percent 0.0%SI: Soft interrupt consumption percent 0.0%st: virtual machine occupancy percentage

The last two behavior memory information. The contents are as follows:

Mem:
Total physical memory of 191272k
Total physical memory used by 173656k used
17616k free Memory Total
The amount of memory that 22052k buffers uses as the kernel cache

Total Swap Area 192772k
Total swap area used by 0k used
192772k free Swap area total
123988k cached Buffer The total amount of swap, in-memory content is swapped out to the swap area, and then swapped into memory, but the used swap area has not been overwritten, the value is that the content already exists in the memory of the swap area, the corresponding memory will be swapped out when the swap area can no longer write.

The details of each process are shown below the process information area statistics area. Let's start by understanding the meaning of the columns.

Ordinal  column name    meaning
A PID process ID
b PPID parent Process ID
C ruser Real user name
D UID process owner's user ID
E username of user process Owner
Group Name of the F group Process owner
The terminal name of the G TTY boot process. Processes that are not started from the terminal are displayed as?
H PR -Priority
I NI nice value. Negative values indicate high priority, positive values indicate low priority
The last CPU used by J P is meaningful only in a multi-CPU environment
K %cpu CPU time consumption percentage last updated to current
The total CPU time, in seconds, used by the timing process
The total CPU time used by the M time+ process, in units 1/100 seconds
N The percentage of physical memory used by the%MEM process
o The total amount of virtual memory used by the VIRT process, in kilobytes. Virt=swap+res
The P swap process uses the size of the virtual memory, which is swapped out, in kilobytes.
The size of the physical memory, in kilobytes, that the Q RES process uses and has not been swapped out. Res=code+data
R Code executable code occupies the physical memory size, in kilobytes
The amount of physical memory that is used outside of the S data executable code (data segment + stack), in kilobytes
T SHR shared memory size, in kilobytes
U nflt page Error count
V NDRT The number of pages that have been modified in the last write to now.
W S process status (d= non-interruptible sleep state, r= run, s= sleep, t= track/Stop, z= zombie process)
X command name/command line
Y Wchan If the process is sleeping, the system function name in sleep is displayed
Z flags task flag, reference sched.h

By default, only the more important PID, USER, PR, NI, VIRT, RES, SHR, S,%cpu,%MEM, time+, and COMMAND columns are displayed. You can change the display by using the following shortcut keys.

Change the display by using the F key to select what to display. Press the F key to display a list of columns, press A-Z to show or hide the corresponding column, and then press ENTER to confirm.
Press the o key to change the order in which the columns are displayed. A-Z in the lower case moves the corresponding column to the right, while the uppercase A-Z moves the corresponding column to the left. Finally, press ENTER to confirm.
Press the uppercase F or O key, and then press A-Z to sort the process by the appropriate column. The uppercase R Key can reverse the current sort.


command to use

Top Use Format

Top [-] [d] [P] [Q] [C] [C] [s] [s] [n]


Parameter description








Other useful commands
The following are some of the interactive commands that you can use during the execution of the top command. From a point of view of use, mastering these commands is more important than mastering the options. These commands are single-letter, and if you use the S option in command-line options, some of these commands may be masked out.



K














W writes the current settings to the ~/.TOPRC file. This is the recommended way to write top configuration files.

Memory and Process Management

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.