0

Is there a way to display the program name? Like in windows when you open the task manager, it will display the program name instead of the directory under COMMAND

EDIT: Commands I used so far

ps aux | grep chromium

Output under COMMAND:

/usr/lib/chromium-browser/chromium-browser

EDIT 2: I found a command called top and under COMMAND it shows the program name, is there a way doing the same in ps?

| improve this question | | | | |
  • Since top's output is suitable for you, can you try ps -e | grep chromium ? – Haxiel Oct 9 '18 at 8:39
1

Try pgrep -l chromium command. It will give you PID and command name. If you want to have more detailed output you can use pgrep and for loop with ps command:

for PROC in $(pgrep chromium)
do
    ps -p $PROC -o pid,uid,gid,time,ucmd
done

Make sure you use ucmd not cmd because cmd will give you full path instead of executable name. Of course you can modify output by changing -o options. You can find all available fields in man ps under section STANDARD FORMAT SPECIFIERS

| improve this answer | | | | |
0

Try the below command,

ps aux | grep < program name>

E.g.:

ps aux | grep httpd
| improve this answer | | | | |
  • i tried that and i get a directory like /usr/lib/chromium-browser/chromium-browser I want to get the program name like chromium – Jay Lee Oct 9 '18 at 6:50
  • 1
    @JayLee There is no way for ps to figure out that a process is running a program called something special other than what the executable file is called. – Kusalananda Oct 9 '18 at 7:06
  • @Kusalananda That's what i want, the executable file, i was using an example like chromium-browser, in ps it shows the directory under COMMAND, but in top it shows the executable file, how do i show the executable file in ps – Jay Lee Oct 9 '18 at 7:10
  • @JayLee /usr/lib/chromium-browser/chromium-browser is an executable file. /usr/lib/chromium-browser/ is a directory. /usr/bin/chromium-browser is a shell script that execs /usr/lib/chromium-browser/chromium-browser, so that's the executable associated with that process. – muru Oct 9 '18 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.