
試してみましたが動作しませんps -eo euser,ruser,suser,fuser,f,comm,label | grep processname
誰もがこれを行う正しい方法を教えてもらえますか?
答え1
ps
Linuxオプションとフィールド名をFreeBSDオプションとキーワードにマッピングしようとしていますps
。これはLinux様システムとBSDスタイルシステムの主な違いの一つです。
まず、-e
FreeBSDのオプションは次のことをps
意味します。「環境図表示」。実際に望むのは、すべてのプロセスを表示することです-ax
。 FreeBSDの場合、-x
端末を制御しないプロセス(カーネルプロセスとデーモン)も表示することです。デフォルトの動作はこれを表示しないことです。
Linuxのps
各フィールド選択情報(からman ps
):
euser EUSER effective user name. This will be the textual user ID, if it can be obtained and the field width
permits, or a decimal representation otherwise. The n option can be used to force the decimal
representation. (alias uname, user).
ruser RUSER real user ID. This will be the textual user ID, if it can be obtained and the field width permits,
or a decimal representation otherwise.
suser SUSER saved user name. This will be the textual user ID, if it can be obtained and the field width permits,
or a decimal representation otherwise. (alias svuser).
fuser FUSER filesystem access user ID. This will be the textual user ID, if it can be obtained and the field
width permits, or a decimal representation otherwise.
f F flags associated with the process, see the PROCESS FLAGS section. (alias flag, flags).
comm COMMAND command name (only the executable name). Modifications to the command name will not be shown.
A process marked <defunct> is partly dead, waiting to be fully destroyed by its parent. The output in
this column may contain spaces. (alias ucmd, ucomm). See also the args format keyword, the -f option,
and the c option.
When specified last, this column will extend to the edge of the display. If ps can not determine
display width, as when output is redirected (piped) into a file or another command, the output width
is undefined. (it may be 80, unlimited, determined by the TERM variable, and so on) The COLUMNS
environment variable or --cols option may be used to exactly determine the width in this case. The w
or -w option may be also be used to adjust width.
label LABEL security label, most commonly used for SE Linux context data. This is for the Mandatory Access
Control ("MAC") found on high-security systems.
ps
各キーワード選択のFreeBSDマニュアルから:
uid effective user ID (alias euid)
user user name (from UID)
ruid real user ID
ruser user name (from ruid)
svuid saved UID from a setuid executable
state symbolic process state (alias stat)
comm command
label MAC label
明確なFreeBSDと同等のものはありませんフューザーだからスキップします。
したがって、あなたの場合は、次のように翻訳されます。
ps -axo user,ruser,svuid,state,comm,label |grep <process_name>
答え2
なしで行う方法は次のとおりですps
。
awk '{
if ("awk" == $1)
print "PID:",$2,"EUID:",$12,"EGID:",$13,"Groups:",$14;
}' /proc/*/status
"awk"
テスト中に適切に交換してくださいif
。特定のプロセスを確認するには、if
テストを削除して特定のプロセスIDに置き換えます。*