52

adb shell ps not working in O android release

adb shell ps command in Android O release is listing only ps process information, but it is not listing all the processes information of all the process like it used to do it in earlier android releases

what is the command to list all the processes information in android O release?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
be_good_do_good
  • 4,311
  • 3
  • 28
  • 42

2 Answers2

85

adb shell ps -A is listing all processes in android-8.0-O release.

I think Google has upgraded ps binary in this release.

be_good_do_good
  • 4,311
  • 3
  • 28
  • 42
  • What's the output your getting – be_good_do_good Apr 10 '18 at 11:11
  • I am getting null string when i am reading after executing process – Jyoti JK Apr 10 '18 at 11:25
  • Got your code from another company question, let me try and update – be_good_do_good Apr 10 '18 at 13:36
  • Hi @be_good_do_good I am only getting list of process by system not getting any root process so any solution for that ? I am applying this command progrmatically and I am getting process which are aquired by same user not from root or system. Any solution for this ? – Gevaria Purva Jan 11 '21 at 04:38
  • As long as process is running, it will be listed irrespective of user. Are you sure your processes is still running? – be_good_do_good Jan 11 '21 at 04:44
  • Yes @be_good_do_good process is running. I am sure on that because I am running that system process manually. When I am running the same command in windows it gives me process data of system, root and user but when I am progrmatically firing same command in device it gives me data of user only. This is how I am running the commandd in android. Process p = Runtime.getRuntime().exec("ps"); – Gevaria Purva Jan 11 '21 at 10:09
  • @be_good_do_good when I run it via machine terminal, it lists all processes but, when I run it in the Android app code, it only lists the app process and ps process! – Dr.jacky Mar 03 '23 at 15:40
24

Answer is: ps -A

But, there are so many new options in ps. Try running ps --help

generic_x86:/ $ ps --help
usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]

List processes.

Which processes to show (selections may be comma separated lists):

-A  All processes

-a  Processes with terminals that aren't session leaders

-d  All processes that aren't session leaders

-e  Same as -A

-g  Belonging to GROUPs

-G  Belonging to real GROUPs (before sgid)

-p  PIDs (--pid)

-P  Parent PIDs (--ppid)

-s  In session IDs

-t  Attached to selected TTYs

-T  Show threads

-u  Owned by USERs

-U  Owned by real USERs (before suid)

Output modifiers:

-k  Sort FIELDs in +increasing or -decreasting order (--sort)

-M  Measure field widths (expanding as necessary)

-n  Show numeric USER and GROUP

-w  Wide output (don't truncate fields)

Which FIELDs to show. (Default = -o PID,TTY,TIME,CMD)

-f  Full listing (-o USER:12=UID,PID,PPID,C,STIME,TTY,TIME,ARGS=CMD)

-l  Long listing (-o F,S,UID,PID,PPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD)

-o  Output FIELDs instead of defaults, each with optional :size and =title

-O  Add FIELDS to defaults

-Z  Include LABEL
nkalra0123
  • 2,281
  • 16
  • 17