'ps' without kernel threads
Asked Answered
A

4

7

I'm looking for some solutions to use ps auxf command to show all processes without kernel threads, or maybe anyone know any else program to filter that kernel process?

What I've tried and found:

ps --ppid 2 -p 2 --deselect

OK, but the processes are not arranged like in the usual 'ps aux':

ps axl | awk '$7 != 0 && $10 !~ "Z"'

much more chaos in result

ps auxf | grep -v ]$

In my opinion, it's a stupid solution to cut out after this sign. There are normal processes with ' [ ] '

It would be great if there was a switch like: -k -- show kernel threads :) and any other option would only show the system processes beginning with Init. Then, using ps aux or ps auxf would be more convenient.

Someone? something? knows any better solution.

Alleyne answered 22/1, 2018 at 11:17 Comment(0)
C
11

It's the u in ps aux which defines the output columns. You can use:

ps u --ppid 2 -p 2 --deselect
Celebrated answered 22/1, 2018 at 14:6 Comment(4)
According to man ps :: Commands options such as ps -aux are not recommended as it is a confusion of two different standards. According to the POSIX and UNIX standards, the above command asks to display all processes with a TTY (generally the commands users are running) plus all processes owned by a user named "x". If that user doesn't exist, then ps will assume you really meant ps aux.Blondie
Sure, but how is that related to my answer?Celebrated
What I meant to say is that I believe you have a typo : ps aux vs ps -auxBlondie
I see. Yeah, that was a typo.Celebrated
G
0
ps -ef | awk '$3!= "2" {print $0}'
Giles answered 10/9, 2020 at 13:4 Comment(0)
A
0

--deselect/-N negates all conditions, not only those --ppid 2 and --pid 2.
There is a better way:

LIBPROC_HIDE_KERNEL=1 ps faxu # <-- or your beloved keys ...
Approach answered 22/10, 2023 at 12:26 Comment(0)
P
0
ps -He -o ppid,pid,user,c,stime,tty,time,comm|grep -Pv '^ +2 +|^ +0 +2 '
Performative answered 13/8, 2024 at 16:50 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.