Skip to content

Commit 2ccfaa2

Browse files
committed
Add method to get process uid, ref mzlogin#43
1 parent 7691e72 commit 2ccfaa2

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

README.en.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Other languages: [:cn: Chinese](./README.md)
1111
# ![Table of Contents](./assets/toc.png)
1212

1313
<!-- vim-markdown-toc GFM -->
14+
1415
* [Basic Usage](#basic-usage)
1516
* [Command syntax](#command-syntax)
1617
* [Targeting equipment for command](#targeting-equipment-for-command)
@@ -97,6 +98,7 @@ Other languages: [:cn: Chinese](./README.md)
9798
* [More adb shell command](#more-adb-shell-command)
9899
* [See process](#see-process)
99100
* [View real-time resource consumption](#view-real-time-resource-consumption)
101+
* [query process uid](#query-process-uid)
100102
* [Other](#other)
101103
* [common problem](#common-problem)
102104
* [Start adb server failure](#start-adb-server-failure)
@@ -2130,6 +2132,32 @@ Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [
21302132
-h displays help documentation
21312133
```
21322134

2135+
### query process uid
2136+
2137+
There are two methods:
2138+
2139+
1. `adb shell dumpsys package <packagename> | grep userId=`
2140+
2141+
For example:
2142+
2143+
```sh
2144+
$ adb shell dumpsys package org.mazhuang.guanggoo | grep userId=
2145+
userId=10394
2146+
```
2147+
2148+
2. Get pid by `ps` first, then `adb shell cat /proc/<pid>/status | grep Uid`
2149+
2150+
For example:
2151+
2152+
```sh
2153+
$ adb shell
2154+
gemini:/ $ ps | grep org.mazhuang.guanggoo
2155+
u0_a394 28635 770 1795812 78736 SyS_epoll_ 0000000000 S org.mazhuang.guanggoo
2156+
gemini:/ $ cat /proc/28635/status | grep Uid
2157+
Uid: 10394 10394 10394 10394
2158+
gemini:/ $
2159+
```
2160+
21332161
### Other
21342162

21352163
The following is a brief description of other commonly used commands, has previously spoken commands no special additional explanation:

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Other languages: [:gb: English](./README.en.md)
1111
# ![Table of Contents](./assets/toc.png)
1212

1313
<!-- vim-markdown-toc GFM -->
14+
1415
* [基本用法](#基本用法)
1516
* [命令语法](#命令语法)
1617
* [为命令指定目标设备](#为命令指定目标设备)
@@ -97,6 +98,7 @@ Other languages: [:gb: English](./README.en.md)
9798
* [更多 adb shell 命令](#更多-adb-shell-命令)
9899
* [查看进程](#查看进程)
99100
* [查看实时资源占用情况](#查看实时资源占用情况)
101+
* [查看进程 UID](#查看进程-uid)
100102
* [其它](#其它)
101103
* [常见问题](#常见问题)
102104
* [启动 adb server 失败](#启动-adb-server-失败)
@@ -2157,6 +2159,32 @@ Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [
21572159
-h 显示帮助文档
21582160
```
21592161

2162+
### 查看进程 UID
2163+
2164+
有两种方案:
2165+
2166+
1. `adb shell dumpsys package <packagename> | grep userId=`
2167+
2168+
如:
2169+
2170+
```sh
2171+
$ adb shell dumpsys package org.mazhuang.guanggoo | grep userId=
2172+
userId=10394
2173+
```
2174+
2175+
2. 通过 ps 命令找到对应进程的 pid 之后 `adb shell cat /proc/<pid>/status | grep Uid`
2176+
2177+
如:
2178+
2179+
```sh
2180+
$ adb shell
2181+
gemini:/ $ ps | grep org.mazhuang.guanggoo
2182+
u0_a394 28635 770 1795812 78736 SyS_epoll_ 0000000000 S org.mazhuang.guanggoo
2183+
gemini:/ $ cat /proc/28635/status | grep Uid
2184+
Uid: 10394 10394 10394 10394
2185+
gemini:/ $
2186+
```
2187+
21602188
### 其它
21612189

21622190
如下是其它常用命令的简单描述,前文已经专门讲过的命令不再额外说明:

0 commit comments

Comments
 (0)