当前位置:网站首页>Process management command

Process management command

2022-04-23 17:57:00 *Flowers bloom on the street

process : One is in progress ( function ) The program ( Dynamic )

Program : It consists of one instruction after another

Process by operating system management

pcb  Process control block ( Store the attribute information of the process )  struct task_struct;

int  pid  Unique identification of the process Process id Number

The process consists of three states : be ready     function     Blocking

The difference between program and process :

1、  A program is an ordered collection of instructions , It's a static concept , Its ability has no meaning of operation . A process is an execution of a program on a processor , It's a dynamic concept .

2、  The program can be stored as a kind of software data for a long time , The process has a certain life cycle , It can produce and die dynamically .

3、  A process is a unit that can run independently , Can work in parallel with other processes .

4、  Process is the basic unit that competes for the limited resources of computer system , It is also the basic unit for processor scheduling . The program has no such concept .

5、  There is no one-to-one correspondence between processes and programs . Different processes can contain the same program , Multiple processes can also be generated during the execution of the same program .

6、  A program is an ordered collection of instructions recorded on a medium , The process is controlled by the program 、 Data and process control blocks 3 Part of it is made up of .

One 、ps Check the process   bash command interpreter

which See where the program is located

ps  By default, only Current terminal Process in (ppid The parent process id, The parent process produces a child process )

ps -e View all process information

ps -A View all process information

ps -f See more processes

ps -ef  See more details

ps -L  Displays the linearity of the process ID

pstree Print out the displayed process information in the form of tree view

 

shell Is the general term of command interpreter ,(eg: Student ) bash  One of the command interpreters (eg: Zhang San . Li Si )

  Two 、kill end ( Kill ) process

( To end a process, you need to know the of the process pid Number )(kill Send semaphores to the process )

kill pid Number ( Programs running in the background and foreground can kill )

ctrl+c( Can only kill the foreground running )

-9(-SIGKILL) Force the end of a process

-STOP Suspend a process ( Actively suspend the execution of the process ,CPU No longer allocate resources to this process )

sleep  sleep ( Commands are executed one by one ,sleep After execution, the next program can be executed )

  for example : We're going to end sleep 200 This process , We need to know its pid( You can find it at another terminal pid), End it again

 

  3、 ... and 、 Stop the process ( Stop the process , But don't end it )

       ctrl+z

Four 、jobs Check the system backstage Running commands ( Displays the tasks of the current terminal )

  5、 ... and 、 Force kill process

kill  -9 pid Number

  6、 ... and 、pkill End process by name

End a group of processes with the same name

pkill Process name

pkill -9 Process name ( End of the mandatory )

7、 ... and 、 & Running programs in the background

command &

command &

The default command is executed in the foreground , Only one at a time , The next... Cannot be executed until the previous one is executed

Programs running in the background can only use kill Kill ,Ctrl+c Cannot end a program running in the background

8、 ... and 、 The foreground task is transferred to the background

bg % task number

  Nine 、 The task is transferred from the background to the foreground

fg % task number

Ten 、top View system resource usage and process information

( amount to windows Task manager )

 

Select the process number and press f Displays detailed information about the selected process

Press   q  sign out

11、 ... and 、 User management command

1、 The file in which the system stores user information
/etc/passwd          Store basic user information
/etc/group          Information graph theory technology for storing user groups
/etc/shadow         Store the user's password
2 、 Add new user
useradd   newname         Add a new user newname
Options :
-g Execute the new user's primary group
-G Add a new user to the subgroup
-s Specifies the default for new users shell terminal
-d Specify the default directory for new users to log in
Creating a new user requires an administrator , After creating a new user , Will be in /home Generate the user's home directory .
3、 Change user password
passwd  user name
4、 Delete user
userdel When deleting users , First, make sure that the user is not logged in .userdel By default, only users are deleted , Will not delete home items
Record the files in the home directory , If you want to delete the user and remove the home directory , So use userdel -r username.

版权声明
本文为[*Flowers bloom on the street]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230547207523.html