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

The usage of the Linux basic command pgrep

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

Share

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

This article mainly explains "the usage of the Linux basic command pgrep". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command pgrep".

Pgrep

The pgrep instruction can search for a specified process by name or other attributes, showing the id of the process to standard output.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Pgrep [- flvx] [- d delimiter] [- n |-o] [- P ppid,...] [- g pgrp,...] [- s sid,...] [- u euid,...] [- U uid,...] [- G gid,...] [- t term,...] [pattern]

2. List of options

Option

Description

-- help

Show help documentation

-- version

Show command version

-d delimiter

Sets the string used to separate the ID of each process in the output (default is newline character). (pgrep only)

-f

Find the completed file name

-g pgrp

Only processes in the listed process group ID are matched. Process group 0 is converted to pgrep or pkill's own process group.

-G gid

Only the processes listed in the actual group ID are matched. You can use numeric or symbolic values.

-l

List the name and id of the process

-n

Select the most recently executed process

-o

Select the earliest process

-P ppid

Select a process that matches the parent pid

-s sid

Only the processes listed in the process session ID are matched. Session ID 0 is converted to pgrep or pkill's own session ID.

-t term

Find a process that matches the terminal number

-u euid

Matches only the processes listed by its valid user ID.

-U uid

Only the processes listed by the actual user ID are matched. You can use numeric or symbolic values.

-v

Find processes that do not meet the criteria

-x

Matches only processes whose name (if-f specifies the command line) exactly matches the pattern.

3. Examples

1) View the specified process information

[root@localhost ~] # pgrep-l wc / / display name and process number

8572 wc

2) View the progress of a terminal

[root@localhost ~] # pgrep-l-t tty1 / / displays the process id and process name under tty1

7734 Xorg

Thank you for your reading, the above is the content of "the usage of the Linux basic command pgrep". After the study of this article, I believe you have a deeper understanding of the usage of the Linux basic command pgrep, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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