• 周四. 10 月 3rd, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Common commands in Linux (4)

King Wang

1 月 3, 2022

One .ps Use of commands

            Linux Medium ps The order is Process Status Abbreviation .ps The command is used to list the processes currently running in the system .ps The command lists a snapshot of the current processes ,

            ps The processes of that moment of command , If you want to dynamically display process information , You can use top command .

            Use relevant parameters :

                     
      a   Show all processes
      -a Display all programs under the same terminal
      -A Show all processes
      c   Show the real name of the process
      -N Reverse selection
      -e be equal to “-A”
      e   Show environment variables
      f   Show the relationship between programs
      -H Show tree structure
       r   Show the current terminal’s progress
      T   Display all programs of the current terminal
      u   Specify all processes for the user
      -au Display more detailed information
      -aux All tours include displays of other users  
      -C< command > List the status of the specified command
      –lines< Row number > Lines per page
      –width< Number of characters > Number of characters per page
      –help Display help information
      –version Show version show

 

 

             

F  A flag representing the program  (flag), 4  On behalf of the user  super user

S  Represents the state of the program  (STAT)

UID  The program should be  UID  Owned by

PID  This is the program  ID !

PPID  It’s the parent program ID

C CPU  Percentage of resources used

PRI  This is  Priority ( Priority of execution )  Abbreviation , Detailed introduction later

NI  This is  Nice  value , In the next section, we will continue to introduce

ADDR  This is  kernel function, Point out which part of memory the program is in . If it’s a  running The program , It is commonly  “-“

SZ  Used memory size

WCHAN  Is the program currently in operation , if  –  Indicates that it is in operation

TTY  The location of the login’s terminal

TIME  Used up  CPU  Time .

CMD  What are the instructions given

In the presupposition , ps  Only the  bash shell  Relevant  PID  nothing more , therefore ,  When I use  ps -l  When , There are only three  PID.

 

 

ps aux

Output :

 

USER: The process Belong to that user account
PID : The process Number
%CPU: The process Used up CPU Percentage of resources
%MEM: The process Percentage of physical memory used
VSZ : The process Amount of virtual memory used (Kbytes)
RSS : The process A fixed amount of memory occupied (Kbytes)
TTY : The process It works on that terminal , If it has nothing to do with the terminal , Is displayed ?, in addition , tty1-tty6 It's the login program on this machine , if pts/0 And so on , It means that the network is connected to the host program .
STAT: The current status of the program , The main states are
R : The program is currently in operation , Or it can be operated
S : The program is currently sleeping ( It can be said that idle state ), But some signals (signal) Wake up the .
T : The program is currently detecting or stopping
Z : The program should have terminated , But his father's program can't stop him normally , cause zombie ( Jiang Zang corpse ) The status of the program
START: The process Time triggered to start
TIME : The process The actual use CPU Time of operation
COMMAND: The actual instructions of the program 

 

Two .linux Related process status of

                   

linux There are 5 States :
1. function ( Running or waiting in the running queue )
2. interrupt ( Sleeping , Blocked , Waiting for a condition to form or receive a signal )
3. Non interruptible ( Received signal does not wake up and cannot run , The process must wait until an interrupt occurs )
4. dead ( The process has terminated , But the process descriptor exists , Until the parent process calls wait4() Release after system call )
5. stop it ( Process received SIGSTOP, SIGSTP, SIGTIN, SIGTOU Stop operation after signal )

ps The tool identifies the 5 State code :
D Non interruptible uninterruptible sleep (usually IO)
R function runnable (on run queue)
S interrupt sleeping
T stop it traced or stopped
Z dead a defunct (”zombie”) process

 

 

3、 … and .kill command

  Used to delete an executing program or work .

 kill The specified information can be sent to the program . The default message is SIGTERM(15), The specified procedure may be terminated . If the program still cannot be terminated , You can use SIGKILL(9) Message attempt to force deletion of program .

grammar

kill [-s < Information name or number >][ Program ] or kill [-l < Information number >]
  • -l < Information number > If not add < Information number > Options , be -l Parameter will list all information names .
  • -s < Information name or number > Specify the message to send .
  • [ Program ] [ Program ] It can be programmed PID or PGID, It can also be the job number .

 

     

The most common signal is :

  • 1 (HUP): Reload process .
  • 9 (KILL): Kill a process .
  • 15 (TERM): Normally stop a process .

Four .env command

      View the environment variables of the current process

     linux The format of the environment variable under the environment key =value:value

   key=value:value:value

Example :

 

5、 … and .top command

 

      top Command is used for real-time display process The dynamics of the

 

  • d : Change the update speed of the display , Or in the conversational command line ( interactive command) Press s
  • q : Display speed without any delay , If the user has superuser Authority , be top Will be executed in the highest order of priority
  • c : Switch display mode , There are two modes , One is to display only the name of the execution file , The other is to show the complete path and name S : Cumulative mode , Will complete or disappear the sub journey ( dead child process ) Of CPU time Add up
  • s : safe mode , Cancel the conversational command , Avoid potential crises
  • i : Do not show any idle (idle) Or useless (zombie) Itinerary
  • n : Number of updates , Will exit when finished top
  • b : Batch file mode , collocation “n” Parameters used together , Can be used to top The results are output to the file

 

 

 

 

 

 

 

 

          

发表回复