I want to see list of process created by specific user or group of user in Linux
Can I do it using ps command or is there any other command to achieve this?
Asked
Active
Viewed 4.4e+01k times
156
Gilles 'SO- stop being evil'
- 807,993
- 194
- 1,674
- 2,175
gaurav VINAYAK shirodkar
- 1,563
- 2
- 10
- 4
-
7`ps -u username`. Most commands have a manual page which you can read with `man the-command`. – Stéphane Chazelas Aug 04 '13 at 09:03
3 Answers
207
To view only the processes owned by a specific user, use the following command:
top -U [username]
Replace the [username] with the required username
If you want to use ps then
ps -u [username]
OR
ps -ef | grep <username>
OR
ps -efl | grep <username>
for the extended listing
Check out the man ps page for options
Another alternative is to use pstree wchich prints the process tree of the user
pstree <username or pid>
Stormvirux
- 2,996
- 3
- 21
- 25
-
3All ` ... | grep
` solutions don't work if you have two usernames which are longer than N chars. In my case N is 6. – guettli Jan 19 '18 at 10:44 -
1Note: I got an error for `top -U [username]`, and `top -u [username]` worked for me instead. Debian 9. So if anybody else gets an error with the -U form, try the lowercase. – Gloweye Oct 29 '18 at 09:08
-
1
7
try this one
ps -fp $(pgrep -u <username>)
user939407
- 71
- 1
- 1
-
How is this better than `ps -u
`, as mentioned in the existing answer (or `ps -fu – Stephen Kitt Jan 23 '18 at 08:27` if you want process details)? -
ps -u doesn't provide full process details, but ps -fu
does. Agree ps -fu is a best solution – user939407 Jan 24 '18 at 10:03 -
1
Note that -e (show all processes) overrides -u and makes it be ignored.
I was passing -e all the time without knowing what the option does, because I usually used ps -ef, and that made -u not work.
So if you want full listing you can keep the -f:
ps -fu USERNAME
Tested on Ubuntu 22.10,
Ciro Santilli OurBigBook.com
- 17,176
- 4
- 113
- 99