<mohammadrony>

PID

ps commands

Process details

ps -ef

Resource usage with process hierarchy

ps auxf

Pid to Process

All process full format

ps -ef | grep <pid>

All process specific format

ps -eo pid,comm | grep <pid>

Selected process and format

ps -o comm -p <pid>
ps -o pid,vsz=MEMORY -o user,group=GROUP -o comm,args=ARGS -p <pid>
ps -o %cpu,%mem,cmd -p <pid>

Selected process full format

ps -f -p <pid>

Pid to Service

sudo systemctl status <pid>

Process to Pid

Process list

ps -ef | grep <process>
ps -eo pid,comm | grep <process>

Process pid

pgrep <process>

# 15+ character process name
pgrep -f <process>

# set process id delimiter
pgrep -d',' <process>
pidof <process>

Pid by user

pgrep -u root <process>
pgrep -u root,daemon

Service to Pid

systemctl status <service> | grep 'Main PID'
systemctl show --property=MainPID <service>

Port to Pid

sudo fuser <port>/tcp
netstat -nltup | grep :<port>
ss -nltup | grep :<port>

Process Tree

Display process tree

pstree -p <pid>

Others

cat /proc/<pid>/status