Use -o flag.
To list only your own processes
ps -o command
To list all system processes
ps -e -o command
This is not the only way to list commands, they can either be printed with command line flags, or as executable only (which is what command option does).
From my comment bellow the answer:
command, args, and cmd all give full command. In fact man page states
command and cmd are aliases for args , with the - flags included. The
comm gives the name of the exacutable only. Aliases to that are ucmd
and ucomm. I misread about AIX options, those can be actually
specified with printf-like format, %a for args, %c for comm
Refer to man ps for more info on usage and available format options
Programmatic approach would be a bit redundant , since ps already provides us with the formatting options, but it can be done with awk, which is much useful when dealing with columnized output.
ps aux | awk '{ for(i=1;i<=NF;i++) {if ( i >= 11 ) printf $i" "}; printf "\n" }'
Note however, that this code breaks if username contains whitespace, e.g. john doe. This can be amended with adding gsub function that will elimiate your username from the ps list. However, if there is multiple users logged into system, that may be difficult to errase all of the usernames from the output. Thus, you can see that -o flag is much more preferred.
Side note, sudo is not necessary to for listing all processes with ps
ps -eo command&ps -eo comm? The only difference I found was incommandthe output was as such:[kthreadd]whereas incommthe output was as this:kthreadd. Does this signify anything? – Raphael Nov 18 '15 at 07:19commis AIX format, where ascommandis standard GNU style format. AIX is another *NIX like system, so that option may be used for compatability. Otherwise, no difference – Sergiy Kolodyazhnyy Nov 18 '15 at 07:24diff <(ps -eo comm) <(ps -eo command)and there seems to be quite a rattle down there, can you clarify? – Andrew Nov 18 '15 at 07:42awksolution breaks if an username contains spaces (here); also maybe justps aux | awk '{ for(i=11;i<=NF;i++) {printf $i" "}; printf "\n" }'? – kos Nov 18 '15 at 07:59command,args, andcmdall give full command. In fact man page statescommandandcmdare aliases forargs, with the-flags included. Thecommgives the name of the exacutable only. Aliases to that areucmdanducomm. I misread about AIX options, those can be actually specified with printf-like format, %a for args, %c for comm – Sergiy Kolodyazhnyy Nov 18 '15 at 08:08pscould do so much on its own. I agree withps -osuiting all situtations. – Andrew Nov 18 '15 at 08:19command=args=cmd, and they all show full command. Example, it would showmyScript.sh -flag 1 -flag 2. Whereas,commonly showsmyScript.sh– Sergiy Kolodyazhnyy Nov 18 '15 at 08:22argcontains the command with all arguments whilecommdisplays the command alone as you had illustrated in your examples, thanks! Wondering whyargshas so many aliases... – Andrew Nov 18 '15 at 08:34pscommand differed from system to system: there's BSD options in there, AIX, probably others. It's not onlypsthing , many other programs have extra options for compatibility – Sergiy Kolodyazhnyy Nov 18 '15 at 08:37-fflag – Sergiy Kolodyazhnyy Nov 18 '15 at 08:40pson the man page, there is a line that says subject to change! I thought this was de-facto. I think the older version would've been better... and now-fmust be obsolete. – Andrew Nov 18 '15 at 08:58COMMAND), just add symbol=(i.e.ps -o command=) or use option--no-header(the latter may be unsupported). – kirikaza Apr 27 '18 at 06:55