In Linux environments with multiple users and long‑running services, understanding which processes belong to which accounts is essential for troubleshooting and capacity planning. Focusing output on a specific user or group makes it easier to spot runaway tasks, stuck daemons, or resource‑heavy applications without scrolling through the entire process table.
Each process is tagged with real and effective user and group identifiers, and common utilities such as ps, pgrep, and top can filter on these attributes. Options like -u and -U select processes based on usernames or user IDs, while -g and -G narrow results to particular groups or process group leaders to match exactly the context being investigated.
Security settings on some distributions restrict how much detail is visible for processes owned by other users, and inspecting system‑wide activity often requires elevated privileges. Using the correct selectors avoids accidentally hiding important processes and helps keep focus on the accounts or groups that matter, especially when working on remote servers or shared Linux systems.
Steps to list processes by user and group in Linux:
- Show processes for a single user with the ps command using both real and effective user selectors.
$ ps -u user -U user PID TTY TIME CMD 781 ? 00:00:00 sleep 782 ? 00:00:00 sleepThe -u option lists processes for a specific user by username, while -U filters by real user ID.
-U Display the processes belonging to the specified real user IDs. -u Display the processes belonging to the specified usernames.
user is a real user and group name in the system.
$ id uid=1001(user) gid=1001(user) groups=1001(user)
- Show processes for a single group with the ps command using group selectors.
$ ps -g user -G user PID TTY TIME CMD 778 ? 00:00:00 sudo 779 ? 00:00:00 sudo 781 ? 00:00:00 sleep 782 ? 00:00:00 sleepThe -g option selects by session or process group leader, and -G selects by real group ID or group name.
-G Display information about processes which are running with the specified real group IDs. -g Display information about processes with the specified process group leaders.
- List processes for multiple users at once with the ps command.
$ ps -u user,root -U user,root PID TTY TIME CMD 1 ? 00:00:00 systemd 24 ? 00:00:00 systemd-journal 64 ? 00:00:00 systemd-udevd 129 ? 00:00:00 cron 138 ? 00:00:00 systemd-logind 147 tty1 00:00:00 agetty 778 ? 00:00:00 sudo 779 ? 00:00:00 sudo 780 ? 00:00:00 sudo 781 ? 00:00:00 sleep ##### snipped #####Multiple usernames or IDs can be provided as comma‑separated lists to combine filters for -u, -U, -g, and -G.
- Filter the ps process list by name or user with the grep command.
$ ps -aef | grep avahi root 780 1 0 21:54 ? 00:00:00 sudo -u avahi bash -lc exec -a avahi-daemon sleep 300 avahi 783 780 0 21:54 ? 00:00:00 avahi-daemon 300 root 812 0 0 21:54 pts/2 00:00:00 bash -lc ps -aef | grep avahi root 821 812 0 21:54 pts/2 00:00:00 grep avahi
The grep command filters process output by keyword, which can be a username, group name, or process name.
- Show processes for a specific user interactively with the top command.
$ top -u user top - 21:55:00 up 1 day, 23:23, 0 user, load average: 0.44, 0.48, 0.55 Tasks: 17 total, 1 running, 16 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni, 99.1 id, 0.0 wa, 0.0 hi, 0.9 si, 0.0 st MiB Mem : 7836.8 total, 1473.1 free, 1623.1 used, 4944.0 buff/cache MiB Swap: 1024.0 total, 1024.0 free, 0.0 used. 6213.6 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 781 user 20 0 5688 1760 1660 S 0.0 0.0 0:00.00 sleep 782 user 20 0 5688 1756 1660 S 0.0 0.0 0:00.00 sleep ##### snipped #####The top command provides real‑time monitoring of CPU and memory usage for processes owned by the specified user.
top accepts either -u or -U, but not both at the same time, and combining them results in a selection error.
$ top -u user -U user top: conflicting process selections (U/p/u)
- Display processes for a user using pgrep and include process names in the output.
$ pgrep -l -u user -U user 781 sleep 782 sleep
The pgrep command lists process IDs filtered by user or group, and the -l flag adds the associated process names to the output.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
