Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to find the process and terminate the process operation by linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "linux how to find the process and terminate the process operation", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "linux how to find the process and terminate the process operation"!

When using the linux operating system, it is inevitable to encounter some software "jam" problems, so you need to use the powerful kill command under linux to end the related process. This is extremely easy under linux. All you need is kill xxx, where xxx represents the process PID number associated with the running of the software.

First, we need to use another command under linux, ps, to find the process-related PID number: ps aux | grep program_filter_word

1) ps a displays all programs under the current terminal, including those of other users.

2) ps-A shows all programs.

3) when ps c lists programs, it displays the real instruction name of each program, without the path, parameter, or resident service tag.

4) ps-e this parameter has the same effect as specifying the "A" parameter.

5) when ps e lists programs, it displays the environment variables used by each program.

6) ps f displays the tree structure with ASCII characters to express the relationship between programs.

7) ps-H shows a tree structure, indicating the relationship between programs.

8) ps-N displays all programs except those under the ps instruction terminal.

9) ps s displays the status of the program in the format of program signals.

10) when ps S lists the program, it includes the interrupted subroutine data.

11) ps-t specifies the terminal number and lists the status of the programs that belong to the terminal.

12) ps u displays the program status in a user-oriented format.

13) ps x displays all programs, not distinguished by terminals.

The most common method is ps aux, and then use the grep command through the pipe to filter to find a specific process, and then operate on a specific process.

Second, use the kill command to end the process: kill xxx

1) function

The kill command is used to abort a process.

2) format

Kill [- s signal |-p] [- a] pid...

Kill-l [signal]

3) parameters

-s: specifies the signal to be sent.

-p: analog transmission signal.

-l: specifies the name list of the signal.

Pid: the ID number of the process to be aborted.

Signal: indicates a signal.

4) description

Process is a very important concept in Linux system. Linux is a multitasking operating system on which multiple processes are often running at the same time. We don't care how these processes are allocated, or how the kernel manages the allocated time slices, what we care about is how to control these processes so that they can serve users well.

The Linux operating system includes three different types of processes, each with its own characteristics and attributes. An interactive process is a process started by a Shell. Interactive processes can be run either in the foreground or in the background. The batch process has no connection with the terminal and is a process sequence. The monitoring process (also known as the system daemon) is a process that starts when the Linux system starts and runs in the background. For example, httpd is the monitoring process of the famous Apache server.

The kill command works by sending a system operation signal and the process identification number of a program to the kernel of the Linux system, and then the kernel can operate on the process specified by the process identification number. For example, in the top command, we see that the system is running many processes, and sometimes we need to use kill to abort certain processes to improve system resources. When explaining the installation and login commands, it was mentioned that the function of multiple virtual consoles of the system is that when a program goes wrong and causes the system deadlock, you can switch to another virtual console to close the program. The command used at this point is kill, because kill is something that most Shell internal commands can call directly.

5) Application examples

(1) forcibly abort (often kill) a process with identification number 324:

# kill-9 324

(2) unlock the Linux system

It sometimes happens in Linux that a program crashes and is in a deadlock state. At this point, there is generally no need to restart the computer, just stop (or close) the problematic program. When kill is in the X-Window interface, the main programs (except for crashed programs) are generally started normally. At this point, open a terminal and abort the problematic program there. For example, if a Mozilla browser program is locked, you can use the kill command to abort all programs that contain Mozolla browsers. First use the ps command to find the program's PID, and then use the kill command to stop the program:

# kill-SIGKILL XXX

Where XXX is the process identification number of the program that contains the Mozolla browser.

(3) use the command to reclaim memory

We know that memory is very important to the system, and recycling memory can improve system resources. The kill command can stop some "deviant" programs in time or have no corresponding programs for a long time. For example, to find a Zombie process using the top command, you can use the following command:

# kill-9 XXX

Where XXX is a useless process identification number.

Then use the following command:

# free

At this point, you will find that the amount of available memory has increased.

(4) killall command

Linux also provides a killall command that can directly use the name of the process instead of the process identification number, for example:

# killall-HUP inetd

At this point, I believe you have a deeper understanding of "linux how to find the process and terminate the process operation". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report