Linux~Common commands ps (view process information), top (monitor Linux system status), netstat (check the network connection of each port of the machine)

PS command

Function: Mainly to view the process information of the server at this time , that is to say, it returns static data, which will not change dynamically

That is to say, the ps command lists the snapshots of the current processes, that is, the processes at the moment when the ps command is executed. If you want to display process information dynamically, you can use the top command.

There are 5 states of process on linux:

Running (running or waiting in the run queue)
interrupt (sleeping, blocked, waiting for the formation of a certain condition or receiving a signal)
uninterruptible (not awakened or runnable when the signal is received, the process must wait until an interrupt occurs)
Zombie (the process has been terminated, but the process descriptor exists, until the parent process calls the wait4() system call and released)
stop (the process stops running after receiving the SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU signal)

So the ps tool identifies the 5 status codes of the process:

D Uninterruptible uninterruptible sleep (usually IO)
R Runnable (on run queue)
S Interrupted sleeping
T Stopped or stopped
Z dead a defunct ("zombie") process

Command parameters

a Display all processes
-a Display all programs under the same terminal
-A Display all processes
c Display the real name of the process
-N Reverse selection
-e equal to "-A"
e Display environment variables
f Display the relationship between programs
-H Display tree structure
r display the current progress of the terminal
T displays the current terminal of all programs
of all processes for the specified user u
-au display more detailed information
-aux show all users comprise other stroke
-C <command> lists the conditions specified command
- lines<number of lines> the number of lines displayed on each page
-width<number of characters> the number of characters displayed on each page
-help display help information
-version display version display

Our most commonly used, ps -ef | grep 进程名which means to filter out all the information of the process status that we want to view in the results of ps

top command

The top command is often used to monitor the status of the Linux system. It is a commonly used performance analysis tool that can display the resource occupancy of each process in the system in real time.

Note that it is a dynamic detection tool

Parameter explanation

-d: number represents the number of seconds, which represents the interval between updates of the page displayed by the top command. The default is 5 seconds.
-b: Execute top in batches.
-n: Used in conjunction with -b to indicate that the output of the top command needs to be performed several times.
-p: Specify a specific pid process number for observation.
?: Display the commands that can be entered in the top
P : display in the order of CPU usage resources
M: display in the order of memory usage resources
N: display in the order of pids
T: display in cumulative order of the time used by the process
k: display for a certain pid A signal. Can be used to kill the process
r: re-customize a nice value (that is, priority) for a pid
q: exit top (you can also exit top with ctrl+c).

netstat command

Function description: Netstat is used to display statistical data related to IP, TCP, UDP and ICMP protocols, and is generally used to check the network connection of each port of the machine.

Use the netstat command to let you know the network situation of the entire Linux system.

Parameter explanation

-a or -all displays all sockets in the connection.
-A<network type> or -<network type> List the relevant addresses in the connection of this network type.
-c or -continuous lists the network status continuously.
-C or -cache Display the cache information of the router configuration.
-e or -extend displays other related information about the network.
-F or -fib displays FIB.
-g or -groups Display the list of group members for the multi-broadcast function.
-h or -help online help.
-i or -interfaces displays the network interface information form.
-l or -listening displays the Socket of the server under monitoring.
-M or -masquerade shows the network connection in disguise.
-n or -numeric use the IP address directly, not through the domain name server.
-N or -netlink or -symbolic Displays the symbolic link name of the network hardware peripheral device.
-o or -timers display timers.
-p or -programs Display the program identification code and program name of the Socket being used.
-r or -route displays the Routing Table.
-s or -statistice displays the statistics table of network work information.
-t or -tcp displays the connection status of the TCP transport protocol.
-u or -udp displays the connection status of the UDP transport protocol.
-v or -verbose displays the process of command execution.
-V or -version Display version information.
-w or -raw displays the connection status of the RAW transfer protocol.
-x or -unix The effect of this parameter is the same as specifying the "-A unix" parameter.
–Ip or –inet The effect of this parameter is the same as the specified "-A inet" parameter

We used a mix is netatst -anp | gerp pidconscious is to filter out what we want to see the port at this time, and then determine whether to use the kill command to kill!

Guess you like

Origin blog.csdn.net/Shangxingya/article/details/114226380