[Bash] ps & pgrep commands

ps

The ps command is used to display information about running processes.
This command displays a snapshot of the current processes.

Common Options:

  • aux: Displays all processes in a detailed format.
  • -e: Shows all processes.
  • -f: Displays full-format listing.
# Display all running processes:
ps aux

Display all processes in full-format listing:
# ps -e

pgrep

The pgrep command searches for processes based on name and other attributes.

pgrep process_name

This command returns the process IDs of all processes with the given name.

# Find the process ID of a process named
$ pgrep postgres

473
592
593
594
595
596
597

# Find the process IDs and names of a process named bash:
$ pgrep -l postgres

473 postgres
592 postgres
593 postgres
594 postgres
595 postgres
596 postgres
597 postgres

# Find the process IDs of processes for a specific user:
$ pgrep -u username
posted @   Zhentiw  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2023-05-24 [HTML 5] Detect visualViewport change
2023-05-24 [React Typescript] useRef with HTML Elements
2023-05-24 [Rust] Option vs Result
2023-05-24 [Rust] Handle Error
2023-05-24 [Rust] Option
2022-05-24 [Next.js] Override the Default Next.js Document
2022-05-24 [Next.js] Override the Default App Component in Next.js
点击右上角即可分享
微信分享提示