I have tried this but doesn't work
ps -eo euser,ruser,suser,fuser,f,comm,label | grep processname
can anyone show me the right way to do this?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You are trying to map Linux
ps options and field name to FreeBSD
ps options and keywords : this is one of the main obvious differences between a linux-like system and a BSD-style one.
-e option on FreeBSD
ps means "Display the environment as well".
What you want is in fact displaying all processes, that is
-ax for FreeBSD;
-x is to display also processes without a controlling terminal (kernel processes and daemons) and the default behavior is not to display them.
ps about per field selection (from
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 manual about per keyword selection:
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
There is no obvious FreeBSD equivalent to fuser, so let's skip it.
So, in your case it would translate to:
ps -axo user,ruser,svuid,state,comm,label |grep <process_name>