The psgrep
command is a handy utility in Unix-like operating systems for searching through the currently running processes. It’s essentially a combination of the ps
and grep
commands, making it easier to find specific processes without having to manually filter the output of ps
.
Here’s how you can use psgrep
:
- Basic Usage: To search for a process by name, simply type
psgrep
followed by the name of the process. For example, to find all instances of a process namedfirefox
, you would use:
psgrep firefox
- This command lists all processes that have the word “firefox” in their description.
- Case Sensitivity: By default,
psgrep
searches are case sensitive. You can make your search case-insensitive by using the-i
option:cssCopy codepsgrep -i firefox
- Show Full Command: To see the full command line used to start each process (which can be truncated in standard output), use the
-f
option:Copy codepsgrep -f firefox
- Display Only PIDs: If you’re only interested in the Process IDs (PIDs), you can use the
-o
option:
psgrep -o firefox
- Exclude Certain Processes: You can exclude certain processes from the search results using the
--exclude
option. For example, to exclude thepsgrep
process itself
psgrep firefox --exclude psgrep
- Help and Options: For a full list of options and more detailed help, you can always run
psgrep
with the--help
flag
grep --help
Remember, psgrep
may not be installed by default on all Unix-like systems, so you might need to install it first using Brew, Apt or Yum.