Summary of ps -ef | grep command in Linux (process view ps/ps -ef, process shutdown kill pid, pipe operator |, grep text search tool/ps -ef | grep)

ps -ef | grep: The command is used to find the running process in the Linux or Unix system
. For example: ps -ef | grep ddspress Enter to find the process of ddscxxPublisher, etc., if the process is running

At this time, if you want to kill the process, then: the process number of a process found by pressing Enter for kill PID
this PIDps -ef | grep dds

Instruction decomposition, where:


psis process statusan abbreviation for (process state). It is used to display information about currently running processes.
(not complete, and does not show detailed completion process information)

-efis one of the options of the ps command. Among them -e, means to display all processes, -fmeans to display complete process information, as shown in the figure below, the detailed information of all processes detected by the ps -ef command:

Please add a picture description


|is the pipe symbol used to pass the output of one command as input to another command .


grepis a powerfultext search tool, which finds lines matching a pattern in the given text .

How to use: grep -i [搜索词] [文件名]
grep -i zhongguo /etc/duzhong.txt: /etcFind zhongguothe matching line in the /duzhong.txt file in this directory, -iindicating that it is not case-sensitive

If line numbers are displayed to:grep -n -i zhongguo /etc/duzhong.txt

This method is only to search outside the file, if you have opened a file: vim ./duzhong.txt, and then look for a certain line in it (search for matching lines in vim mode)

Just /follow the item you want to find, and then press the Enter key

Then N means the previous one, n means the next one, just switch to the found item


To sum up, ps -ef | grepthe function of the command is to pass the output of the ps -ef command to the grep command for filtering and searching. Use this command to find specific process information based on keywords or patterns.

Please add a picture description

For example, if you want to find all processes starting with "httpd", you can use the following command:

ps -ef | grep httpd
This command will first execute ps -ef to obtain all running process information, and then pass the result to the grep command for filtering. grep httpd will search for lines matching "httpd" and display the results, so you can see all process information containing "httpd".

Use the ps -ef | grep command to easily find and filter process information, helping you quickly locate and operate specific processes.

Guess you like

Origin blog.csdn.net/qq_42595610/article/details/132300420