-Uを使用したコマンドの処理

-Uを使用したコマンドの処理
ps -f -U

このコマンドが何をしているのか理解できません。上記のコマンドの出力を取得しましたが、理解できませんでした。

ベストアンサー1

このpsオプションには、-U表示するプロセスのユーザーのリスト(またはより正確にはプロセスが実行されているユーザー名)を含める必要があります。目的は、明らかにユーザー名でフィルタリングすることです。

このような:

$ ps -f -U syslog,avahi                                                                                                                                                                                                                     
UID        PID  PPID  C STIME TTY          TIME CMD
syslog     522     1  0 10月22 ?      00:00:00 /usr/sbin/rsyslogd -n
avahi      594     1  0 10月22 ?      00:00:00 avahi-daemon: running [eagle.local]
avahi      622   594  0 10月22 ?      00:00:00 avahi-daemon: chroot helper

psこのオプションはFreeBSDとcoreutilsの両方に存在します。POSIX規格だから私はそれがかなり移植可能なオプションだと思います。

-fcoreutilsのマニュアルによると、次のようになりますps

   -f     Do full-format listing. This option can be combined with many other UNIX-style options to add additional columns.  It also causes the command arguments to be printed.  When used with -L, the NLWP (number of threads)
          and LWP (thread ID) columns will be added.  See the c option, the format keyword args, and the format keyword comm.

しかし、FreeBSDマニュアルには次のように記載されています。

 -f      Show command-line and environment information about swapped out
     processes.  This option is honored only if the UID of the user is
     0.

したがって、目標はどちらの場合も出力の完全な形式を取得することですが、説明は非常に異なります。さらに、FreeBSDオプションには置き換えられたプロセスを含めないでください。これは失われたので携帯性が悪いです。OpenBSD マニュアル

おすすめ記事