ps -ef | grep
: The command is used to find the running process in the Linux or Unix system
. For example: ps -ef | grep dds
press 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:
ps
is process status
an abbreviation for (process state). It is used to display information about currently running processes.
(not complete, and does not show detailed completion process information)
-ef
is one of the options of the ps command. Among them -e
, means to display all processes, -f
means to display complete process information, as shown in the figure below, the detailed information of all processes detected by the ps -ef command:
|
is the pipe symbol used to pass the output of one command as input to another command .
grep
is 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
: /etc
Find zhongguo
the matching line in the /duzhong.txt file in this directory, -i
indicating 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 | grep
the 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.
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.