参考:Linux pgrep Command Tutorial for Beginners (10 Examples)

Linux命令——ps、pstree

bash基础——grep、基本正则表达式、扩展正则表达式、fgrep

这个命令也是用来查看进程(或线程)信息的。可以理解成是ps+grep

举例

根据用户ID,用户名查找进程(或线程)

使用-u参数。

这一点要称赞pgrep,不像ps(-u接uid,-U接username),-u可以包含uid和username两种情况

[root@localhost lib]# pgrep -u 0 -d:
1:2:3:5:7:8:9:10:11:12:13:14:16:17:18:19:21:22:23:24:26:27:28:29:30:31:32:33:34:36:37:38:39:40:41:42:43:44:45:46:48:49:50:51:52:53:54:55:56:57:63:64:65:66:74:75:76:77:78:79:80:93:94:128:148:323:324:325:333:334:335:336:337:338:339:342:343:357:360:363:421:422:432:433:447:448:449:450:451:452:453:454:455:456:457:458:527:554:563:591:605:661:662:663:664:665:666:667:668:669:671:672:676:680:681:682:683:684:685:686:687:708:741:742:750:759:767:917:918:942:1004:1005:1006:1017:1098:1265:1271:1287:1288:1289:1293:1341:1426:1994:2126:2151:2210:2229
[root@localhost lib]# pgrep -u root -d:
1:2:3:5:7:8:9:10:11:12:13:14:16:17:18:19:21:22:23:24:26:27:28:29:30:31:32:33:34:36:37:38:39:40:41:42:43:44:45:46:48:49:50:51:52:53:54:55:56:57:63:64:65:66:74:75:76:77:78:79:80:93:94:128:148:323:324:325:333:334:335:336:337:338:339:342:343:357:360:363:421:422:432:433:447:448:449:450:451:452:453:454:455:456:457:458:527:554:563:591:605:661:662:663:664:665:666:667:668:669:671:672:676:680:681:682:683:684:685:686:687:708:741:742:750:759:767:917:918:942:1004:1005:1006:1017:1098:1265:1271:1287:1288:1289:1293:1341:1426:1994:2126:2151:2210:2229
View Code

相关文章: