Find all processes by user linux

How to see process created by specific user in Unix/linux

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?

3 Answers 3

To view only the processes owned by a specific user, use the following command:

Replace the [username] with the required username

If you want to use ps then

Check out the man ps page for options

Another alternative is to use pstree wchich prints the process tree of the user

All ` . | grep ` solutions don’t work if you have two usernames which are longer than N chars. In my case N is 6.

Note: 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.

How is this better than ps -u , as mentioned in the existing answer (or ps -fu if you want process details)?

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 :

Читайте также:  Linux find version ubuntu

You must log in to answer this question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

How to list all processes by non-root users?

Update: The original solution is practically equivalent to another one, below, just uses xargs instead of $(…) :

pgrep -vu root | xargs ps u 

+1 (assuming $IFS contains its default value). Or ps aux | awk ‘$1 != «root»‘ (assuming no usernames contain blanks characters).

This works in Fedora 35 (ps from procps-ng 3.3.17):

Personally I always use the f flag. Makes reading the output easier: ps fu -N -u root

This works on my Debian systems, and my macOS 10.15. It may be a bit of overkill for this requirement, but it’s fairly adaptable to other requirements:

ps -eo pid,stat,ruser,command | awk '< if ($3 != "root") print $0;>' PID STAT RUSER COMMAND 312 Ssl systemd+ /lib/systemd/systemd-timesyncd 349 Ss avahi avahi-daemon: running [raspberrypi4b.local] 359 Ss nobody /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user nobody --deviceglob /dev/input/event* 365 Ss message+ /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only 393 S avahi avahi-daemon: chroot helper 620 Ss vnstat /usr/sbin/vnstatd -n 910 Ss Debian-+ /usr/sbin/exim4 -bd -q30m 2193 R+ pi ps -eo pid,stat,ruser,command 2194 S+ pi awk < if ($3 != "root") print $0;># alternatively, for a more compact output: ps -eo pid,ruser | awk '< if ($2 != "root") print $0;>' PID RUSER 312 systemd-timesync 349 avahi 359 nobody 365 messagebus 393 avahi 620 vnstat 910 Debian-exim 2204 pi 2205 pi 

note: listings above are not complete; culled for brevity

ps -e shows every process on the system using standard syntax ( aux is BSD syntax)

ps -eo the -o option is one of several listed in the OUTPUT FORMAT CONTROL section of man ps that may be used to choose what information is displayed by ps . Why clutter your output with stuff you don’t care about? If you want it all, ps -e is all you need.

Читайте также:  Xerox phaser 3250 driver linux

ps -eo pid,stat,ruser,command the -o option allows selection of output parameters by using one or more of the keywords listed in man ps under the STANDARD FORMAT SPECIFIERS section. In this example, ps lists all PIDs, process states, real user IDs and the command that spawned them. Once again, see the STANDARD FORMAT SPECIFIERS section of man ps for the complete list of keywords.

The pipe to awk simply filters all root user processes, and of course is easily modified to filter on other fields in the ps output.

Источник

Linux List All Processes by Name, User, PID

list all processes linux

Many times you need to list all processes in Linux to find out which processes are running, if a user is running any process, or if a specific process is running. Here’s how to list all processes by name, user, PID. You can use it to list all processes in Ubuntu, CentOS, Fedora, Redhat, and other Linux systems

How to List all Processes in Linux

Here are the steps to list all processes in Linux/Unix. There are various commands like ps, top, htop and pgrep to list all processes in Linux. We will use ps command to list processes.

Open terminal and run the following command to list all processes in Linux.

$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 24336 2284 ? Ss Sep01 0:02 /sbin/init root 2 0.0 0.0 0 0 ? S Sep01 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S Sep01 0:00 [ksoftirqd/0] root 4 0.0 0.0 0 0 ? S Sep01 0:00 [kworker/0:0] .

In the above command,
a = show processes for all users
u = display the process’s user/owner
x = also show processes not attached to a terminal

Читайте также:  Write permissions linux directory

The above command will list all running processes.

List all processes by User

Here’s the command to list all processes by a specific user, say, john

In the above command,
-u : Show all processes by RUID
-U : Display all processes by EUID

You can also use top or pgrep commands to list processes by user in Linux.

List Processes by Name

Here’s the command to list all processes by a specific name, say, firefox

In the above command, we pass the output of ps aux to grep command and search for string “firefox”.
You can also use pgrep command for this purpose. It searches the current running processes and lists PIDs of matching processes.

List Processes by PID

Here’s the command to list all processes by a specific PID, say, 1234

Hopefully, now you can easily list all processes in Linux/Unix.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it today!

Источник

Оцените статью
Adblock
detector