Process and program processes and programs
Program: a binary program is typically copied to a storage medium and exists as a physical file.
Process: After a program is triggered, the executor's permissions and attributes, program code, and required data are loaded into the memory, the operating system gives the memory unit an identifier PID, that is, the process is a running program.
Job Control Work Management
Foreground foreground FG
Background BG
Pause Ctrl + z
Directly drop the command to the background for execution &
For example, extract a large compressed package:
Tar-zpcvf/tmp/etc.tar.gz/etc &
Tar-zpcvf/tmp/etc.tar.gz/etc>/tmp/log.txt 2> & 1 &
View backend jobs
When calling: FG jobnumber
Kill and kill Processes
-9 force process killing
-15 normally killed by default
Process view PS top
PS is static view process top is dynamic view
PS
-All processes of a are displayed as-e.
-A is not related to all terminal Processes
-U Valid users
X is usually used with a to list complete information.
L long and detailed list of the PID Information
J working format
-F complete output
View your own bash-related processes PS-l
F indicates the flag permission of the process.
Generally, 4 indicates the root permission. If it is 1, the sub-process can only copy fork but cannot actually execute it.
S indicates the Process status
R running the process is running
S sleep this process is sleeping and can be awakened
D. The sleep state that cannot be awakened may be waiting for Io.
T The stop status may be work control or debugging.
Z zombie process has been terminated but cannot be deleted out of memory
UID/Pid/ppid this process is owned by the UID process id pid and the parent process ppid
C Indicates CPU usage unit percentage
PRI/Ni: the smaller the CPU processing priority, the faster the process is executed.
ADDR/sz/wchan ADDR, which part of the process is in the memory? If it is running, it is-SZ, which indicates the amount of memory used by the process. wchan indicates whether the process is running.
If the TTY hacker's terminal location is remote login, the dynamic terminal is used as an excuse for pts/n.
The CPU time used out is the actual CPU running time of the process.
CMD commands triggered by this program
View all processes PS aux
User: The process belongs to the user account.
PID the process identifier of the process
% CPU the percentage of CPU resources used by the Process
% Mem percentage of physical memory occupied by the Process
Vsz virtual memory used by the process in KB
RSS fixed memory kb used by the Process
If the TTY hacker's terminal location is remote login, the dynamic terminal is used as an excuse for pts/n.
Stat the current status of this process is generally R/S/T/Z
Time the actual CPU running time of the process
Command the actual command of the process
Top dynamically view process changes
Top-D + number
-D: the number of seconds added to the backend of the process interface. The default value is 5 seconds.
-B. Executing top in batches usually works with data stream redirection to output the results of batch processing files.
-N and-B must be matched to the top output results several times.
-P specifies a PID for viewing.
During top execution, you can use the following key commands:
? : Key commands that can be entered in top
P: sorted by CPU usage
M: displayed by memory usage Resources
N: sort by PID
T: sorted by CPU time cumulatively. Time +
K: Give a PID a signal
R: Give a PID a new nice value.
Q: Leaving top
Pstree
-The connections between process trees of a are ASCII characters.
-U connections between process trees are UTF-8 characters
-P simultaneously lists the PID of each process
-U simultaneously lists the account names of each process
Process Management kill and killall
Kill-signal PID
Killall-signal command name
-I. If you want to delete a file, a prompt is displayed to the user.
-E exact indicates that the command name to be followed must be
-I case-insensitive
Example:
Killall-l syslogd
Killall-9 httpd termination httpd
Killall-I-9 bash
Kill Bash? (Y/n) users can select
Priority and nice
The lower the PRI value, the more limited it is. But the PRI value is dynamically adjusted by the kernel and cannot be directly adjusted.
PRI (new) = PRI (old) + nice
Nice-N numeric command
Nice-n-5 VI &
The user gives a nice value of-5 to execute VI and view the process.
View System Resources
Free view memory usage
Free-B/-k/-M/-g/-T
Unit displayed during bkmg Input
-T the final output result shows the total physical memory and swap
Uname [-asrmpi]
-A. All system-related information includes all the following data.
-S system kernel name
-R system kernel version
-M hardware name of the system
Similar to-m, the-p cpu type only displays the CPU type.
-I hardware platform
Netstat trace network [-tunlpa]
-A: List all connection listening sockets of the current system.
-T lists TCP network packets
-U: List UDP network data packets
-N does not list the process service names in port numbers.
-L list the services currently being monitored by the Network
-P: list the process PID OF THE NETWORK SERVICE
Data Packet protocols of proto networks are mainly divided into TCP and UDP
Recv-Q total number of bytes copied when the user process is not connected to this socket
The total number of acknowledged bytes sent by the remote host.
Localaddress local IP port status
The State connection status mainly includes creating establised and listening to listen.
Proto is generally Unix
Number of processes that refcnt connects to this socket
Flags connection ID
Type socket access types mainly include confirmed connected streams and dgram that do not need to be confirmed
If the State is connected, a connection has been established between multiple processes.
Path: the path connecting to the socket-related program
Analyze the information generated by the kernel dmesg
Dmesg more
Dmesg | grep-I hd
Detect System Support changes vmstat
Vmstat-a CPU memory and other information
-Fs memory-related
-S display unit
-D is related to the disk.
-P partitions are related to disks.
Parameters:
-A uses inactive/active to replace the Memory output information of buffer/cache.
-F the number of processes that the system copies from the boot to the current position fork
-S: lists the memory changes caused by time.
-S backend unit, for example, K/m
-D: list the total read/write volume of a disk.
-P: List partitions to display the total read/write volume of these partitions.
For example, count the current host CPU status three times per second
Vmstat 1 3
This article from the "years, the city" blog, please be sure to retain this source http://alca0126.blog.51cto.com/7826974/1435273