{"id":809,"date":"2019-04-18T11:51:14","date_gmt":"2019-04-18T03:51:14","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=809"},"modified":"2022-05-06T17:28:04","modified_gmt":"2022-05-06T09:28:04","slug":"ps","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/ps","title":{"rendered":"ps\u547d\u4ee4 – \u663e\u793a\u8fdb\u7a0b\u72b6\u6001"},"content":{"rendered":"\n
ps\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201dprocess status\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u663e\u793a\u5f53\u524d\u7cfb\u7edf\u7684\u8fdb\u7a0b\u72b6\u6001\u3002\u4f7f\u7528ps\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5230\u8fdb\u7a0b\u7684\u6240\u6709\u4fe1\u606f\uff0c\u4f8b\u5982\u8fdb\u7a0b\u7684\u53f7\u7801\u3001\u53d1\u8d77\u8005\u3001\u7cfb\u7edf\u8d44\u6e90\u4f7f\u7528\u5360\u6bd4\uff08\u5904\u7406\u5668\u4e0e\u5185\u5b58\uff09\u3001\u8fd0\u884c\u72b6\u6001\u7b49\u7b49\u3002\u5e2e\u52a9\u6211\u4eec\u53ca\u65f6\u7684\u53d1\u73b0\u54ea\u4e9b\u8fdb\u7a0b\u51fa\u73b0\u201d\u50f5\u6b7b\u201c\u6216\u201d\u4e0d\u53ef\u4e2d\u65ad\u201c\u7b49\u5f02\u5e38\u60c5\u51b5\u3002<\/p>\n\n\n\n
\u7ecf\u5e38\u4f1a\u4e0ekill\u547d\u4ee4\u642d\u914d\u4f7f\u7528\u6765\u4e2d\u65ad\u548c\u5220\u9664\u4e0d\u5fc5\u8981\u7684\u670d\u52a1\u8fdb\u7a0b\uff0c\u907f\u514d\u670d\u52a1\u5668\u7684\u8d44\u6e90\u6d6a\u8d39\u3002<\/p>\n\n\n\n
\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>ps [\u53c2\u6570] <\/p>\n\n\n\n \u5e38\u7528\u53c2\u6570\uff1a\ufeff<\/strong><\/p>\n\n\n\n \u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n \u663e\u793a\u7cfb\u7edf\u4e2d\u5168\u90e8\u7684\u8fdb\u7a0b\u4fe1\u606f\uff0c\u542b\u8be6\u7ec6\u4fe1\u606f\uff1a<\/p>\n\n\n\n \u7ed3\u5408\u8f93\u51fa\u91cd\u5b9a\u5411\uff0c\u5c06\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\u4fdd\u7559\u5907\u4efd\u81f3\u6307\u5b9a\u6587\u4ef6\uff1a<\/p>\n\n\n\n \u7ed3\u5408\u7ba1\u9053\u64cd\u4f5c\u7b26\uff0c\u5c06\u5f53\u524d\u7cfb\u7edf\u8fd0\u884c\u72b6\u6001\u4e2d\u6307\u5b9a\u8fdb\u7a0b\u4fe1\u606f\u8fc7\u6ee4\u51fa\u6765\uff1a<\/p>\n\n\n\n \u7ed3\u5408\u7ba1\u9053\u64cd\u4f5c\u7b26\uff0c\u5c06\u5f53\u524d\u7cfb\u7edf\u8fd0\u884c\u72b6\u6001\u4e2d\u6307\u5b9a\u7528\u6237\u7684\u8fdb\u7a0b\u4fe1\u606f\u8fc7\u6ee4\u51fa\u6765\uff1a<\/p>\n\n\n\n \u7ed3\u5408\u7ba1\u9053\u64cd\u4f5c\u7b26\u4e0esort\u547d\u4ee4\uff0c\u4f9d\u636e\u5904\u7406\u5668\u4f7f\u7528\u91cf\uff08\u7b2c\u4e09\u5217\uff09\u60c5\u51b5\u964d\u5e8f\u6392\u5e8f\uff1a<\/p>\n\n\n\n \u7ed3\u5408\u7ba1\u9053\u64cd\u4f5c\u7b26\u4e0esort\u547d\u4ee4\uff0c\u4f9d\u636e\u5185\u5b58\u4f7f\u7528\u91cf\uff08\u7b2c\u56db\u5217\uff09\u60c5\u51b5\u964d\u5e8f\u6392\u5e8f\uff1a<\/p>\n\n\n\n ps\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201dprocess status\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u663e\u793a\u5f53\u524d\u7cfb\u7edf\u7684\u8fdb\u7a0b\u72b6\u6001\u3002\u4f7f\u7528ps\u547d\u4ee4 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/809"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=809"}],"version-history":[{"count":36,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/809\/revisions"}],"predecessor-version":[{"id":9321,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/809\/revisions\/9321"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}a<\/td> \u663e\u793a\u73b0\u884c\u7ec8\u7aef\u673a\u4e0b\u7684\u6240\u6709\u7a0b\u5e8f\uff0c\u5305\u62ec\u5176\u4ed6\u7528\u6237\u7684\u7a0b\u5e8f<\/td><\/tr> -A<\/td> \u663e\u793a\u6240\u6709\u7a0b\u5e8f<\/td><\/tr> c<\/td> \u663e\u793a\u6bcf\u4e2a\u7a0b\u5e8f\u771f\u6b63\u7684\u6307\u4ee4\u540d\u79f0\uff0c\u800c\u4e0d\u5305\u542b\u8def\u5f84<\/td><\/tr> -C <\u6307\u4ee4\u540d\u79f0><\/td> \u6307\u5b9a\u6267\u884c\u6307\u4ee4\u7684\u540d\u79f0\uff0c\u5e76\u5217\u51fa\u8be5\u6307\u4ee4\u7684\u7a0b\u5e8f\u7684\u72b6\u51b5<\/td><\/tr> -d<\/td> \u663e\u793a\u6240\u6709\u7a0b\u5e8f\uff0c\u4f46\u4e0d\u5305\u62ec\u9636\u6bb5\u4f5c\u4e1a\u7ba1\u7406\u5458\u7684\u7a0b\u5e8f<\/td><\/tr> e<\/td> \u5217\u51fa\u7a0b\u5e8f\u65f6\uff0c\u663e\u793a\u6bcf\u4e2a\u7a0b\u5e8f\u6240\u4f7f\u7528\u7684\u73af\u5883\u53d8\u91cf<\/td><\/tr> -f<\/td> \u663e\u793aUID,PPIP,C\u4e0eSTIME\u680f\u4f4d<\/td><\/tr> f<\/td> \u7528ASCII\u5b57\u7b26\u663e\u793a\u6811\u72b6\u7ed3\u6784\uff0c\u8868\u8fbe\u7a0b\u5e8f\u95f4\u7684\u76f8\u4e92\u5173\u7cfb<\/td><\/tr> g<\/td> \u663e\u793a\u73b0\u884c\u7ec8\u7aef\u673a\u4e0b\u7684\u6240\u6709\u7a0b\u5e8f\uff0c\u5305\u62ec\u6240\u5c5e\u7ec4\u7684\u7a0b\u5e8f<\/td><\/tr> -G <\u7fa4\u7ec4\u8bc6\u522b\u7801><\/td> \u5217\u51fa\u5c5e\u4e8e\u8be5\u7fa4\u7ec4\u7684\u7a0b\u5e8f\u7684\u72b6\u51b5<\/td><\/tr> h<\/td> \u4e0d\u663e\u793a\u6807\u9898\u5217<\/td><\/tr> -H<\/td> \u663e\u793a\u6811\u72b6\u7ed3\u6784\uff0c\u8868\u793a\u7a0b\u5e8f\u95f4\u7684\u76f8\u4e92\u5173\u7cfb<\/td><\/tr> -j<\/td> \u91c7\u7528\u5de5\u4f5c\u63a7\u5236\u7684\u683c\u5f0f\u663e\u793a\u7a0b\u5e8f\u72b6\u51b5<\/td><\/tr> -l<\/td> \u91c7\u7528\u8be6\u7ec6\u7684\u683c\u5f0f\u6765\u663e\u793a\u7a0b\u5e8f\u72b6\u51b5<\/td><\/tr> L<\/td> \u5217\u51fa\u680f\u4f4d\u7684\u76f8\u5173\u4fe1\u606f<\/td><\/tr> -m<\/td> \u663e\u793a\u6240\u6709\u7684\u6267\u884c\u7eea<\/td><\/tr> n<\/td> \u4ee5\u6570\u5b57\u6765\u8868\u793aUSER\u548cWCHAN\u680f\u4f4d<\/td><\/tr> -N<\/td> \u663e\u793a\u6240\u6709\u7684\u7a0b\u5e8f\uff0c\u9664\u4e86\u6267\u884cps\u6307\u4ee4\u7ec8\u7aef\u673a\u4e0b\u7684\u7a0b\u5e8f\u4e4b\u5916<\/td><\/tr> -p <\u7a0b\u5e8f\u8bc6\u522b\u7801><\/td> \u6307\u5b9a\u7a0b\u5e8f\u8bc6\u522b\u7801\uff0c\u5e76\u5217\u51fa\u8be5\u7a0b\u5e8f\u7684\u72b6\u51b5<\/td><\/tr> r<\/td> \u53ea\u5217\u51fa\u73b0\u884c\u7ec8\u7aef\u673a\u6b63\u5728\u6267\u884c\u4e2d\u7684\u7a0b\u5e8f<\/td><\/tr> -s <\u9636\u6bb5\u4f5c\u4e1a><\/td> \u5217\u51fa\u96b6\u5c5e\u8be5\u9636\u6bb5\u4f5c\u4e1a\u7684\u7a0b\u5e8f\u7684\u72b6\u51b5<\/td><\/tr> s<\/td> \u91c7\u7528\u7a0b\u5e8f\u4fe1\u53f7\u7684\u683c\u5f0f\u663e\u793a\u7a0b\u5e8f\u72b6\u51b5<\/td><\/tr> S<\/td> \u5217\u51fa\u7a0b\u5e8f\u65f6\uff0c\u5305\u62ec\u5df2\u4e2d\u65ad\u7684\u5b50\u7a0b\u5e8f\u8d44\u6599<\/td><\/tr> -t <\u7ec8\u7aef\u673a\u7f16\u53f7><\/td> \u5217\u51fa\u5c5e\u4e8e\u8be5\u7ec8\u7aef\u673a\u7684\u7a0b\u5e8f\u7684\u72b6\u51b5<\/td><\/tr> -T<\/td> \u663e\u793a\u73b0\u884c\u7ec8\u7aef\u673a\u4e0b\u7684\u6240\u6709\u7a0b\u5e8f<\/td><\/tr> u<\/td> \u4ee5\u7528\u6237\u4e3a\u4e3b\u7684\u683c\u5f0f\u6765\u663e\u793a\u7a0b\u5e8f\u72b6\u51b5<\/td><\/tr> -U <\u7528\u6237\u8bc6\u522b\u7801><\/td> \u5217\u51fa\u5c5e\u4e8e\u8be5\u7528\u6237\u7684\u7a0b\u5e8f\u7684\u72b6\u51b5<\/td><\/tr> U <\u7528\u6237\u540d\u79f0><\/td> \u5217\u51fa\u5c5e\u4e8e\u8be5\u7528\u6237\u7684\u7a0b\u5e8f\u7684\u72b6\u51b5<\/td><\/tr> v<\/td> \u91c7\u7528\u865a\u62df\u5185\u5b58\u7684\u683c\u5f0f\u663e\u793a\u7a0b\u5e8f\u72b6\u51b5<\/td><\/tr> -V\u6216V<\/td> \u663e\u793a\u7248\u672c\u4fe1\u606f<\/td><\/tr> -w\u6216w<\/td> \u91c7\u7528\u5bbd\u9614\u7684\u683c\u5f0f\u6765\u663e\u793a\u7a0b\u5e8f\u72b6\u51b5<\/td><\/tr> x<\/td> \u663e\u793a\u6240\u6709\u7a0b\u5e8f\uff0c\u4e0d\u4ee5\u7ec8\u7aef\u673a\u6765\u533a\u5206<\/td><\/tr> X<\/td> \u91c7\u7528\u65e7\u5f0f\u7684Linux i386\u767b\u9646\u683c\u5f0f\u663e\u793a\u7a0b\u5e8f\u72b6\u51b5<\/td><\/tr> -y<\/td> \u914d\u5408\u9009\u9879”-l”\u4f7f\u7528\u65f6\uff0c\u4e0d\u663e\u793aF(flag)\u680f\u4f4d\uff0c\u5e76\u4ee5RSS\u680f\u4f4d\u53d6\u4ee3ADDR\u680f\u4f4d<\/td><\/tr> --cols <\u6bcf\u5217\u5b57\u7b26\u6570><\/td> \u8bbe\u7f6e\u6bcf\u5217\u7684\u6700\u5927\u5b57\u7b26\u6570<\/td><\/tr> --headers<\/td> \u91cd\u590d\u663e\u793a\u6807\u9898\u5217<\/td><\/tr> --help<\/td> \u5728\u7ebf\u5e2e\u52a9<\/td><\/tr> --info<\/td> \u663e\u793a\u6392\u9519\u4fe1\u606f<\/td><\/tr> --lines <\u663e\u793a\u5217\u6570><\/td> \u8bbe\u7f6e\u663e\u793a\u753b\u9762\u7684\u5217\u6570<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n [root@linuxcool ~]# ps aux<\/strong> \nUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\nroot 2 0.0 0.0 0 0 ? S 20:05 0:00 [kthreadd]\nroot 3 0.0 0.0 0 0 ? I< 20:05 0:00 [rcu_gp]\nroot 4 0.0 0.0 0 0 ? I< 20:05 0:00 [rcu_par_gp]\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n\n\n\n
[root@linuxcool ~]# ps aux > backup.txt<\/strong><\/pre>\n\n\n\n
[root@linuxcool ~]# ps -ef | grep ssh<\/strong>\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n\n\n\n
[root@linuxcool ~]# ps -u root<\/strong>\n PID TTY TIME CMD\n 1 ? 00:00:01 systemd\n 2 ? 00:00:00 kthreadd\n 3 ? 00:00:00 rcu_gp\n 4 ? 00:00:00 rcu_par_gp\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n\n\n\n
[root@linuxcool ~]# ps aux | sort -rnk 3<\/strong>\nUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\nroot 2341 0.4 8.1 4504040 164896 tty2 Sl+ 20:05 0:24 \/usr\/bin\/gnome-shell\nroot 4534 0.3 0.4 220064 8520 ? Ssl 21:37 0:00 \/usr\/libexec\/nm-dispatcher\ngdm 1541 0.1 7.3 4211428 147400 tty1 Sl+ 20:05 0:06 \/usr\/bin\/gnome-shell\n\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n\n\n\n
[root@linuxcool ~]# ps aux | sort -rnk 4<\/strong>\nUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\nroot 2341 0.4 8.1 4503976 164828 tty2 Sl+ 20:05 0:27 \/usr\/bin\/gnome-shell\ngdm 1541 0.1 7.3 4211428 147556 tty1 Sl+ 20:05 0:08 \/usr\/bin\/gnome-shell\nroot 2661 0.0 3.1 1271636 63004 tty2 Sl+ 20:05 0:01 \/usr\/bin\/gnome-software --gapplication-service\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026\n<\/pre>\n","protected":false},"excerpt":{"rendered":"