Add method to get process uid, ref #43

master
Zhuang Ma 7 years ago
parent 7691e721f1
commit 2ccfaa2b56
  1. 28
      README.en.md
  2. 28
      README.md

@ -11,6 +11,7 @@ Other languages: [:cn: Chinese](./README.md)
# ![Table of Contents](./assets/toc.png)
<!-- vim-markdown-toc GFM -->
* [Basic Usage](#basic-usage)
* [Command syntax](#command-syntax)
* [Targeting equipment for command](#targeting-equipment-for-command)
@ -97,6 +98,7 @@ Other languages: [:cn: Chinese](./README.md)
* [More adb shell command](#more-adb-shell-command)
* [See process](#see-process)
* [View real-time resource consumption](#view-real-time-resource-consumption)
* [query process uid](#query-process-uid)
* [Other](#other)
* [common problem](#common-problem)
* [Start adb server failure](#start-adb-server-failure)
@ -2130,6 +2132,32 @@ Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [
-h displays help documentation
```
### query process uid
There are two methods:
1. `adb shell dumpsys package <packagename> | grep userId=`
For example:
```sh
$ adb shell dumpsys package org.mazhuang.guanggoo | grep userId=
userId=10394
```
2. Get pid by `ps` first, then `adb shell cat /proc/<pid>/status | grep Uid`
For example:
```sh
$ adb shell
gemini:/ $ ps | grep org.mazhuang.guanggoo
u0_a394 28635 770 1795812 78736 SyS_epoll_ 0000000000 S org.mazhuang.guanggoo
gemini:/ $ cat /proc/28635/status | grep Uid
Uid: 10394 10394 10394 10394
gemini:/ $
```
### Other
The following is a brief description of other commonly used commands, has previously spoken commands no special additional explanation:

@ -11,6 +11,7 @@ Other languages: [:gb: English](./README.en.md)
# ![Table of Contents](./assets/toc.png)
<!-- vim-markdown-toc GFM -->
* [基本用法](#基本用法)
* [命令语法](#命令语法)
* [为命令指定目标设备](#为命令指定目标设备)
@ -97,6 +98,7 @@ Other languages: [:gb: English](./README.en.md)
* [更多 adb shell 命令](#更多-adb-shell-命令)
* [查看进程](#查看进程)
* [查看实时资源占用情况](#查看实时资源占用情况)
* [查看进程 UID](#查看进程-uid)
* [其它](#其它)
* [常见问题](#常见问题)
* [启动 adb server 失败](#启动-adb-server-失败)
@ -2157,6 +2159,32 @@ Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [
-h 显示帮助文档
```
### 查看进程 UID
有两种方案:
1. `adb shell dumpsys package <packagename> | grep userId=`
如:
```sh
$ adb shell dumpsys package org.mazhuang.guanggoo | grep userId=
userId=10394
```
2. 通过 ps 命令找到对应进程的 pid 之后 `adb shell cat /proc/<pid>/status | grep Uid`
如:
```sh
$ adb shell
gemini:/ $ ps | grep org.mazhuang.guanggoo
u0_a394 28635 770 1795812 78736 SyS_epoll_ 0000000000 S org.mazhuang.guanggoo
gemini:/ $ cat /proc/28635/status | grep Uid
Uid: 10394 10394 10394 10394
gemini:/ $
```
### 其它
如下是其它常用命令的简单描述,前文已经专门讲过的命令不再额外说明:

Loading…
Cancel
Save