Get the App
SLTechnology News&Howtos  ›  Servers  › 

The usage of the Linux basic command pidof

Shulou Source: shulou.com Published: 2022-06-01 12:40:08 10月03日 Update

This article mainly explains "the usage of the Linux basic command pidof". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of the basic Linux command pidof.

Pidof

Pidof can find the pid of a process with a specified name and send the results to standard output. Pidof has two return values: 0, at least one process is found, and 1, no process is found. Pidof is actually the same as killall5; the program operates according to the name that calls it.

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

1. Grammar

Pidof [options] name

2. List of options

Option

Description

S

Respond to only one process number at a time

-c

Only processes running in the root directory are displayed. This option is valid only for root users.

-o

Ignore the process with the specified process number

-x

Also show the same name in the shell script run

3. Examples

1) View the id of the specified process

[root@localhost ~] # pidof bash / / shows the id of the bash process, with two

8563 8266

2) display only one process at a time

[root@localhost ~] # pidof-s bash / / shows only one process id

8563

At this point, I believe you have a deeper understanding of "the use of the Linux basic command pidof". 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!

Tags: Process command foundation name same content actual learning running practical deeper effective two interest at the same time examples practicality in fact simple operation method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology vpn MySQL MariaDB Redmi