You can also note that the PID 1 is systemd, indicating that my Linux system uses systemd. When run, the pstree will show a top-down, tree-like structure output of processes as shown in the picture above. The pstree command, as its name implies, shows a hierarchical view of parent processes and child processes. $ ps -u pratham | grep vimĥ16525 pts/2 SNl+ 0:00 nvim pstree command If I want to filter processes and only want to see if pratham has an active Vim process or not, here is how I find it out. There might be multiple users on my computer using Vim, user pratham and root. You can also use the -u flag (as opposed to u) along with ps command to specify a particular user and filter out the results, making it easier to manage. I would use the following command for that: $ pgrep alacrittyĪs I ran that command, I got four PIDs indicating that four processes match with the pattern 'alacritty' and their PIDs are outputted to the stdout. Let's say, for example, I want to see the PIDs of any process that have the name 'alacritty'. The pgrep command accepts a pattern to match and if there are any processes that match with the provided pattern, a process ID (PID) is returned to stdout.īelow is the syntax to use for pgrep command: pgrep Let's see some other Linux commands to see running processes. The only difference between using ps aux and ps -A is that when you use ps aux, you can easily grep the user, or alternatively, use the -u option. This is because it also has 'alacritty' in the process name (as the argument).īe wary of this behaviour if you use it in a script. Notice how the grep command was also included in the output. Most people, including me, pipe this output in grep to find a needle in the haystack. This will give you an incredibly long list of running processes that were running at the time of executing the ps command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |