This post will guide you how to list all processes for a given user at the shell prompt in your Linux Opearting systems. How do I list all running processes names for my user in Linux.
A Linux Process is a application running in the current Linux distribution, and it is also called as service or daemon. when you start or run an application in your current Linux, and a new process will be created, and also it will havea unique number called as a identification(PID).
List All Processes by User Names
If you want to list all running processes for a given user called “devops“, you can type one of the following commands:
$ ps -u devops $ ps -U devops $ top -U devops $ sudo ps -aux | grep ^devops $ pgrep -l -u devops $ htop -u devops
Outputs:
devops@devops:~$ ps -u devops PID TTY TIME CMD 3639 ? 00:00:00 systemd 3640 ? 00:00:00 (sd-pam) 3740 ? 00:00:00 sshd 3741 pts/3 00:00:00 bash 3900 pts/3 00:00:00 ps devops@devops:~$ ps -U devops PID TTY TIME CMD 3639 ? 00:00:00 systemd 3640 ? 00:00:00 (sd-pam) 3740 ? 00:00:00 sshd 3741 pts/3 00:00:00 bash 3901 pts/3 00:00:00 ps devops@devops:~$ top -U devops top - 18:43:49 up 23 min, 1 user, load average: 0.01, 0.06, 0.14 Tasks: 209 total, 1 running, 175 sleeping, 0 stopped, 0 zombie %Cpu(s): 6.6 us, 2.0 sy, 0.0 ni, 90.1 id, 1.2 wa, 0.0 hi, 0.2 si, 0.0 st KiB Mem : 1006668 total, 419064 free, 303780 used, 283824 buff/cache KiB Swap: 2097148 total, 1652476 free, 444672 used. 552788 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3902 devops 20 0 51332 4032 3312 R 18.8 0.4 0:00.03 top 3639 devops 20 0 76908 8128 6808 S 0.0 0.8 0:00.04 systemd 3640 devops 20 0 261944 2796 0 S 0.0 0.3 0:00.00 (sd-pam) 3740 devops 20 0 110072 5396 4376 S 0.0 0.5 0:00.15 sshd 3741 devops 20 0 29532 4848 3396 S 0.0 0.5 0:00.11 bash devops@devops:~$ sudo ps -aux | grep ^devops devops 3639 0.0 0.8 76908 8128 ? Ss 18:34 0:00 /lib/systemd/systemd --user devops 3640 0.0 0.2 261944 2796 ? S 18:34 0:00 (sd-pam) devops 3740 0.0 0.5 110072 5396 ? S 18:34 0:00 sshd: devops@pts/3 devops 3741 0.0 0.4 29532 4848 pts/3 Ss 18:34 0:00 -bash devops 3916 0.0 0.1 21532 1028 pts/3 S+ 18:47 0:00 grep --color=auto ^devops devops@devops:~$ pgrep -u devops -l 3639 systemd 3640 (sd-pam) 3740 sshd 3741 bash
devops@devops:~$ htop -u devops
Note: the -u option will show all processes by effective user ID or name. And the -U option will show all runing processes by real user ID or name.
You can also display all running processes by both effective User name (EUID) and Real User Name or ID(RUID) with the following ps command:
$ ps -u devops -U devops
Outputs:
devops@devops:~$ ps -u devops -U devops
PID TTY TIME CMD
3639 ? 00:00:00 systemd
3640 ? 00:00:00 (sd-pam)
3740 ? 00:00:00 sshd
3741 pts/3 00:00:00 bash
3899 pts/3 00:00:00 ps
If you want to get more detailed info about those command, and you can see the man page with the following commands:
$ man ps$ man top$ man htop$man pgrep
Conclusion
You should know that how to list all running processes from the command line with ps/top/pgrep/htop commands in CentOS or RHEL or Ubuntu Linux.