Linux环境下Android开发常用命令

  • 搜索类

find 目录 -name 名字


grep命令 -r代表递归

grep -r “内容”

grep -rE ‘内容a|内容b’ 有内容a或者内容b的

grep -r 内容a | grep 内容b 既有a也要有b

将文件中XXX替换成YYY

sed -i ‘s/XXX/YYY/g’ grep XXX . -rl

locate命令

  1. locate的速度比find快,因为它并不是真的查找文件,而是查数据库
  2. locate的查找并不是实时的,而是以数据库的更新为准,一般是系统自己维护
  3. 升级数据库命令:locate – u
  • 查看进程类

ps 查看进程

ps -t 进程号或者grep 命令

  • Android源码编译

source build/envsetup.sh;

lunch

make -j8

  • Android干掉进程类

普通进程,activity manager就能干掉

adb shell am force-stop com.avatar.settings

adb shell ps | grep com.avatar.dialog

adb shell kill 3349

我们还可以直接用ps -t 加进程号 查看该进程的详细情况及其开的子线程个数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
> root@rk3288:/ # ps -t 3308
> USER PID PPID VSIZE RSS WCHAN PC NAME system
> 3308 168 957444 102596 ffffffff 4004e754 S com.avatar.dialog system
> 3312 3308 957444 102596 c007ef6c 4004e920 S GC system 3313 3308
> 957444 102596 c004622c 4004e188 S Signal Catcher system 3314 3308
> 957444 102596 c0115d44 4004d6f0 S JDWP system 3315 3308 957444
> 102596 c007ef6c 4004e920 S Compiler system 3316 3308 957444
> 102596 c007ef6c 4004e920 S ReferenceQueueD system 3317 3308
> 957444 102596 c007ef6c 4004e920 S FinalizerDaemon system 3318 3308
> 957444 102596 c007ef6c 4004e920 S FinalizerWatchd system 3319 3308
> 957444 102596 c05a7d64 4004d5a4 S Binder_1 system 3320 3308
> 957444 102596 c05a7d64 4004d5a4 S Binder_2 system 3321 3308
> 957444 102596 c0140070 4004e754 S Notify system 3322 3308 957444
> 102596 c0140070 4004e754 S WifiManager system 3324 3308 957444
> 102596 c007ef6c 4004e920 S m.avatar.dialog system 3325 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog system 3326 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog system 3327 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog system 3328 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog system 3329 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog system 3336 3308
> 957444 102596 c007ef6c 4004e920 S AsyncTask #1 system 3337 3308
> 957444 102596 c007ef6c 4004e920 S AsyncTask #2 system 3339 3308
> 957444 102596 c007ef6c 4004e920 S CMEM Purge system 3340 3308
> 957444 102596 bf011f64 4004d2e0 S mali-event-hnd system 3341 3308
> 957444 102596 c007ef6c 4004e920 S mali-utility-wo system 3342 3308
> 957444 102596 c007ef6c 4004e920 S mali-utility-wo system 3343 3308
> 957444 102596 c007ef6c 4004e920 S mali-utility-wo system 3344 3308
> 957444 102596 c007ef6c 4004e920 S mali-utility-wo system 3345 3308
> 957444 102596 c007ef6c 4004e920 S mali-renderer system 3346 3308
> 957444 102596 c007ef6c 4004e920 S AsyncTask #3 system 3347 3308
> 957444 102596 c05a7d64 4004d5a4 S Binder_3 system 3352 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog system 3355 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog system 3367 3308
> 957444 102596 c007ef6c 4004e920 S m.avatar.dialog
  • 强启应用命令

adb shell am start -a android.intent.action.MAIN -n com.avatar.settings/.Settings

  • 产生5000次monkey触摸事件

adb shell monkey -v 5000

adb shell monkey -p com.avatar.settings -s 500 -v 10000

  • 查看系统占用率最高的10个线程

top -m 10 -t

  • 使用dumpsys查看系统信息

    dumpsys cpuinfo 查看CPU占用率情况

  • adb录屏幕

    adb shell screenrecord –size 480x320 /sdcard/test2.mp4
    adb shell screenrecord /sdcard/test.mp4
    adb pull /sdcard/test.mp4

  • adb模拟返回键

    adb shell input keyevent 4


谢谢大家阅读,如有帮助,来个喜欢或者关注吧!


本文作者:Anderson/Jerey_Jobs

简书地址 : Anderson大码渣
CSDN地址 : Jerey_Jobs的专栏
github地址 : Jerey_Jobs