bash 如何让ps打印组?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20236582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:47:34  来源:igfitidea点击:

How to get ps to print group?

linuxbashps

提问by user782220

ps auxwill print out something formatted according to the below. It shows the user that the process runs under. But is there a way to display the group that the process runs under?

ps aux将打印出根据以下格式设置的内容。它向用户显示进程在其下运行。但是有没有办法显示进程运行所在的组?

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

回答by devnull

You can specify the desired format:

您可以指定所需的格式:

   o format
          Specify user-defined format.  Identical to -o and --format.

For example, saying:

例如说:

ps o pid,group

would print pidand group.

将打印pidgroup

Saying:

说:

ps o pid,group,gid

would print pid, groupand group ID.

会打印pid,groupgroup ID.



As per your comment, the following might work for you:

根据您的评论,以下内容可能对您有用:

ps o user,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,comm,group,gid

To see all processes:

查看所有进程:

ps ax o user,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,comm,group,gid