{"id":7200,"date":"2022-10-17T10:54:50","date_gmt":"2022-10-17T02:54:50","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=7200"},"modified":"2024-12-31T14:03:33","modified_gmt":"2024-12-31T06:03:33","slug":"ps-%e8%bf%9b%e7%a8%8b%e7%ae%a1%e7%90%86%e6%8c%87%e4%bb%a4","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=7200","title":{"rendered":"ps-\u8fdb\u7a0b\u7ba1\u7406\u6307\u4ee4"},"content":{"rendered":"<p><a href=\"https:\/\/blog.csdn.net\/yspg_217\/article\/details\/121845366\">https:\/\/blog.csdn.net\/yspg_217\/article\/details\/121845366<\/a><\/p>\n<p><a href=\"https:\/\/blog.csdn.net\/qq_44681788\/article\/details\/130902259\">https:\/\/blog.csdn.net\/qq_44681788\/article\/details\/130902259<\/a><\/p>\n<p><a href=\"https:\/\/www.zhihu.com\/question\/378345922\/answer\/2871122003?utm_id=0\">https:\/\/www.zhihu.com\/question\/378345922\/answer\/2871122003?utm_id=0<\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7200\/#%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\" title=\"\u53c2\u6570\u8bf4\u660e\">\u53c2\u6570\u8bf4\u660e<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7200\/#linux%E7%89%88%E6%9C%AC\" title=\"linux\u7248\u672c\">linux\u7248\u672c<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7200\/#android%E7%89%88%E6%9C%AC\" title=\"android\u7248\u672c\">android\u7248\u672c<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=7200\/#%E5%AE%9E%E7%94%A8%E5%9C%BA%E6%99%AF\" title=\"\u5b9e\u7528\u573a\u666f\">\u5b9e\u7528\u573a\u666f<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\"><\/span>\u53c2\u6570\u8bf4\u660e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/download.csdn.net\/blog\/column\/12529139\/135104281\">https:\/\/download.csdn.net\/blog\/column\/12529139\/135104281<\/a><br \/>\n<a href=\"https:\/\/www.cnblogs.com\/zypdbk\/p\/16307104.html\">https:\/\/www.cnblogs.com\/zypdbk\/p\/16307104.html<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"linux%E7%89%88%E6%9C%AC\"><\/span>linux\u7248\u672c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-bash\">root@xinyi-virtual-machine:~# ps --help all\n\n\u7528\u6cd5\uff1a\n ps [\u9009\u9879]\n\n\u57fa\u672c\u9009\u9879\uff1a\n -A, -e               all processes\n -a                   all with tty, except session leaders\n  a                   all with tty, including other users\n -d                   all except session leaders\n -N, --deselect       negate selection\n  r                   only running processes\n  T                   all processes on this terminal\n  x                   processes without controlling ttys\n\nSelection by list:\n -C &lt;\u547d\u4ee4&gt;            \u547d\u4ee4\u540d\u79f0\n -G, --Group &lt;GID&gt;    real group id or name\n -g, --group &lt;group&gt;  session or effective group name\n -p, p, --pid &lt;PID&gt;   \u8fdb\u7a0b\u7f16\u53f7\n        --ppid &lt;PID&gt;  \u7236\u8fdb\u7a0b\u7f16\u53f7\n -q, q, --quick-pid &lt;PID&gt;\n                      process id (quick mode)\n -s, --sid &lt;session&gt;  session id\n -t, t, --tty &lt;tty&gt;   \u7ec8\u7aef\n -u, U, --user &lt;UID&gt;  effective user id or name\n -U, --User &lt;UID&gt;     \u771f\u5b9e\u7528\u6237\u7f16\u53f7\u6216\u540d\u79f0\n\n  The selection options take as their argument either:\n    a comma-separated list e.g. &#039;-u root,nobody&#039; or\n    a blank-separated list e.g. &#039;-p 123 4567&#039;\n\n\u8f93\u51fa\u683c\u5f0f\uff1a\n -F                   extra full\n -f                   \u5b8c\u6574\u683c\u5f0f\uff0c\u5305\u542b\u547d\u4ee4\u884c\n  f, --forest         ascii \u5b57\u7b26\u827a\u672f\u663e\u793a\u7684\u8fdb\u7a0b\u6811\n -H                   show process hierarchy\n -j                   jobs format\n  j                   BSD \u4efb\u52a1\u63a7\u5236\u683c\u5f0f\n -l                   \u957f\u683c\u5f0f\n  l                   BSD \u957f\u683c\u5f0f\n -M, Z                \u6dfb\u52a0\u5b89\u5168\u6570\u636e\uff08\u7528\u4e8e SELinux\uff09\n -O &lt;format&gt;          preloaded with default columns\n  O &lt;format&gt;          as -O, with BSD personality\n -o, o, --format &lt;\u683c\u5f0f&gt;\n                      \u7528\u6237\u5b9a\u4e49\u7684\u683c\u5f0f\n  s                   \u4fe1\u53f7\u683c\u5f0f\n  u                   user-oriented format\n  v                   \u865a\u62df\u5185\u5b58\u683c\u5f0f\n  X                   \u5bc4\u5b58\u5668\u683c\u5f0f\n -y                   do not show flags, show rss vs. addr (used with -l)\n     --context        \u663e\u793a\u5b89\u5168\u4e0a\u4e0b\u6587\uff08\u7528\u4e8e SELinux\uff09\n     --headers        repeat header lines, one per page\n     --no-headers     do not print header at all\n     --cols, --columns, --width &lt;num&gt;\n                      set screen width\n     --rows, --lines &lt;num&gt;\n                      set screen height\n\nShow threads:\n  H                   as if they were processes\n -L                   possibly with LWP and NLWP columns\n -m, m                after processes\n -T                   possibly with SPID column\n\nMiscellaneous options:\n -c                   show scheduling class with -l option\n  c                   show true command name\n  e                   show the environment after command\n  k,    --sort        specify sort order as: [+|-]key[,[+|-]key[,...]]\n  L                   show format specifiers\n  n                   display numeric uid and wchan\n  S,    --cumulative  include some dead child process data\n -y                   do not show flags, show rss (only with -l)\n -V, V, --version     display version information and exit\n -w, w                \u4e0d\u9650\u5236\u8f93\u51fa\u5bbd\u5ea6\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"android%E7%89%88%E6%9C%AC\"><\/span>android\u7248\u672c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>\u7ebf\u7a0b\u663e\u793a-T<br \/>\n\u6ce8\u610flinux\u663e\u793a\u7ebf\u7a0b\u662f-L<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E5%AE%9E%E7%94%A8%E5%9C%BA%E6%99%AF\"><\/span>\u5b9e\u7528\u573a\u666f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\n<p>\u8fdb\u7a0b\u540d\u79f0\u663e\u793a\u4e0d\u5168\u95ee\u9898<br \/>\nps w\u6216\u8005ps x<\/p>\n<\/li>\n<li>\n<p>\u67e5\u627e\u8fdb\u7a0b\u7684\u542f\u52a8\u76ee\u5f55<br \/>\n1.pwdx \u8fdb\u7a0bid<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/wangzy-Zj\/p\/12416278.html\">https:\/\/www.cnblogs.com\/wangzy-Zj\/p\/12416278.html<\/a><br \/>\n2.ll \/proc\/\u8fdb\u7a0bid\/cwd<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/wangzy-Zj\/p\/12416278.html\">https:\/\/www.cnblogs.com\/wangzy-Zj\/p\/12416278.html<\/a><br \/>\n<a href=\"https:\/\/www.cnblogs.com\/exception1\/p\/14665407.html\">https:\/\/www.cnblogs.com\/exception1\/p\/14665407.html<\/a><\/p>\n<\/li>\n<li>\n<p>\u6253\u5370\u8fdb\u7a0b\u53f7<br \/>\n<code>ps -ef | grep &quot;name&quot; | grep -v grep | awk &#039;{print $2}&#039;<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u6216\u8005<code>pgrep -f process_name<\/code><\/p>\n<ul>\n<li>\n<p>\u6253\u5370\u7236\u8fdb\u7a0b\u53f7<br \/>\nps axo pid,ppid | grep 1234<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u5f53\u524dshell\u7684\u8fdb\u7a0b<br \/>\n<code>ps -p $$<\/code><\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u6587\u4ef6\u88ab\u54ea\u4e9b\u8fdb\u7a0b\u5360\u7528<br \/>\nfuser<br \/>\n<a href=\"https:\/\/www.coonote.com\/linux\/linux-cmd-fuser.html\">https:\/\/www.coonote.com\/linux\/linux-cmd-fuser.html<\/a><\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u8fdb\u7a0b\u7684\u8c03\u7528\u6811\u56fe(\u67e5\u770b\u5b50\u8fdb\u7a0b)<br \/>\npstree -p \u8fdb\u7a0b\u53f7<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u7279\u5b9a\u8fdb\u7a0b\u7684SELinux\u4e0a\u4e0b\u6587<br \/>\nps -p PID -Z<\/p>\n<\/li>\n<\/ul>\n<button class=\"simplefavorite-button\" data-postid=\"7200\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/blog.csdn.net\/yspg_217\/article\/details\/121 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[567],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/7200"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7200"}],"version-history":[{"count":21,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/7200\/revisions"}],"predecessor-version":[{"id":15406,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/7200\/revisions\/15406"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7200"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}