Elite Linux commands: pgrep

Gaurav Gandhi
1 min readMar 13, 2018

--

In older times we use to run everything from command line, but now as Linux is getting better GUIs and userbase is increasing of non-techs, we are more using a mouse to do stuff than keyboards.

If we run the something through UI and if it goes non-responsive, generally a popup comes prompting to wait or force close, but even after trying to force close it stuck or popup is not coming, then we have to use a terminal to kill that process.

To kill a process from a terminal, either you should know full command name or pid, sometimes command name is different from what we assume, so killall command will not help. For such scenarios, we can use either use top -b -n 1 | grep string where string is something from command name or we can simply use pgrep -a string to find pid and kill with kill pid command.

There is also pkill command but it will kill before showing the results, so it might kill something undesired. It’s always better to use a two-step process for such tasks.

There are many more such amazing commands, some I will try cover in next stories.

Comment with Feedback, suggestion, and improvements.

--

--

Gaurav Gandhi
Gaurav Gandhi

Written by Gaurav Gandhi

10+ yrs exp. in software dev. Highly versatile and adaptable, learns new tech quickly to deliver top-notch results.

No responses yet