2

I tried T-ui and although it has the lsof command, it cannot do lsof -i for example, so I need to go through every single process in Android. My phone is rooted and I wanna know the PID of the process listening to a specific port. Thanks!

EDIT:
Oh yeah, netstat command also don't allow any option, so if you guys know some terminal with the complete netstat command that would do it.

2

Standard lsof source code has some differences with Android implementation. Android's own /system/bin/lsof or /vendor/bin/lsof (both provided by toybox) work perfectly, but with somewhat limited options.

However, to view listening ports, you have multiple options:

  • netstat static binary compiled from standard source
  • Netstat Plus app
  • Netstat applet shipped with busybox (app or any standalone busybox) or the one that comes bundled with Android (at least on Android Pie, not sure about older versions); /system/bin/netstat or /vendor/bin/netstat (both provided by toybox) also offer enough options
  • ss command; the Android one (standalone binary shipped at least with Pie) i.e. /system/bin/ss or static binary

To view processes:

  • ps static binary compiled from standard source
  • ps applet that comes bundled with Android; /system/bin/ps or /vendor/bin/ps (both provided by toybox) also offer enough options
  • ps provided by Termux (procps-ng package) is a complete Linux ps

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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