From 2ccfaa2b56549df95d2613e2706f2bce29fb9486 Mon Sep 17 00:00:00 2001 From: Zhuang Ma Date: Mon, 23 Oct 2017 15:43:27 +0800 Subject: [PATCH] Add method to get process uid, ref #43 --- README.en.md | 28 ++++++++++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/README.en.md b/README.en.md index 1e5e6b1..c5566bf 100644 --- a/README.en.md +++ b/README.en.md @@ -11,6 +11,7 @@ Other languages: [:cn: Chinese](./README.md) # ![Table of Contents](./assets/toc.png) + * [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 | 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//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: diff --git a/README.md b/README.md index cc9dad5..afb5e96 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Other languages: [:gb: English](./README.en.md) # ![Table of Contents](./assets/toc.png) + * [基本用法](#基本用法) * [命令语法](#命令语法) * [为命令指定目标设备](#为命令指定目标设备) @@ -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 | grep userId=` + + 如: + + ```sh + $ adb shell dumpsys package org.mazhuang.guanggoo | grep userId= + userId=10394 + ``` + +2. 通过 ps 命令找到对应进程的 pid 之后 `adb shell cat /proc//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:/ $ + ``` + ### 其它 如下是其它常用命令的简单描述,前文已经专门讲过的命令不再额外说明: