psgrep


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:

  1. 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 named firefox, you would use:

psgrep firefox

  1. This command lists all processes that have the word “firefox” in their description.
  2. 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
  3. 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
  4. Display Only PIDs: If you’re only interested in the Process IDs (PIDs), you can use the -o option:
psgrep -o firefox
  1. Exclude Certain Processes: You can exclude certain processes from the search results using the --exclude option. For example, to exclude the psgrep process itself
psgrep firefox --exclude psgrep
  1. 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.

This image has an empty alt attribute; its file name is Unix-Basics-fast-cover-1024x683.jpg

GET THE FULL COURSE HERE