user1895268
user1895268

Reputation: 1679

How to find a PID of a process whose name I don't know exactly?

I can get the PID of a specific process name by

pidof$(ps -C netns)

but what if I don't know the name of the process exactly? I can't type something like

pidof$(ps -C net*)

so is there any wildcard character, or is there another solution?

Upvotes: 2

Views: 3263

Answers (4)

Kasravnd
Kasravnd

Reputation: 107287

you can use grep and pip :

pidof$(ps -c |grep yor_pattern)

Upvotes: 0

jlliagre
jlliagre

Reputation: 30803

Just use pgrep -l, eg:

$ pgrep -l sh
1821 sshd
2590 ssh-agent
2658 sh
2677 bash
3025 gvfsd-trash
14785 ksh93
17723 ksh93

Upvotes: 3

Wayne
Wayne

Reputation: 3519

try the following and see if you can discover the process as such

This will give you all processes for all users, in a full-format listing

ps auxf 

where :

  • axu = To see every process on the system using BSD syntax
  • f = fullformat

if the list is too long you can filter if you have an idea of the process name

For example the command below will show you the pids for chrome.

ps auxf | grep chrome 

Upvotes: 0

Jean-Karim Bockstael
Jean-Karim Bockstael

Reputation: 1405

Use the -A (all processes) option and filter the result through grep:

pidof $(ps -A | grep "net*")

Upvotes: 4

Related Questions