码迷,mamicode.com
首页 > 其他好文 > 详细

常用命令汇总

时间:2015-02-28 18:40:49      阅读:1409      评论:0      收藏:0      [点我收藏+]

标签:adb   shell   命令   常用命令   

Android相关:

adb shell ps 得到进程号

adb shell am dumpheap 进程号  /storage/sdcard0/mem.hprof   //倒出hprof文件

adb reboot bootloader//重启进入fastboot模式

fastboot flash system system.img

make snod//产生一个新的系统映像system.img

make ramdisk//编译ramdisk

make userdateimage//编译userdata

make systeyimage//编译system

make bootimage//编译kernel

adb shell top -m 8//查看前8个CPU使用最高的进程

adb shell top -t -m 8//查看前8个CPU使用最高的线程

adb logcat -v time //输出时间信息 LOG

adb logcat -v time -b events //输出带有时间event信息 LOG

adb logcat -v time -s SurfaceFlinger//输出有时间信息并且TAG是SurfaceFlingerLOG

adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq//查看CPU频率

adb shell "echo 0 > /proc/sys/kernel/kptr_restrict sysctl" 在/proc/kallsyms输出的地址都为0时,可以导出符合表

应用打开debug模式:<application ...... android:debuggable="true">

禁止GC的方式:

VMRuntime localVMRuntime;

localVMRuntime = VMRuntime.getRuntime();

localVMRuntime.disableGcForExternalAlloc(true);

localVMRuntime.disableGcForExternalAlloc(false);


填满手机内置U盘空间

adb shell dd if=/dev/zero of=/mnt/sdcard/bigfile

adb shell getevent -lt /dev/input/eventXXX

adb shell showmap PID

adb shell showslab

adb shell procrank

native memory leak:

adb shell mv /system/lib/libc.so /system/lib/libc_original.so

adb shell mv /system/lib/libc_dubug.so /system/lib/libc.so

adb shell setprop persist.libc.debug.malloc 1

adb shell reboot

打印堆栈:

Log.d(TAG,Log.getStackTraceString(new Throwable()));  

得到Client端的uid跟package name:

int uid = Binder.getCallingUid();

String as[] = ((PackageManagerService)ServiceManager.getService("package")).getPackagesForUid(uid);

if(as != null && as[0] != null)

编译内核模块:

make -C ~/src/jb_rel-M8974AAAAANLYA31050148/out/target/product/msm8974/obj/KERNEL_OBJ M=`pwd`  ARCH=arm  CROSS_COMPILE=/opt2/oujunli/src/jb_rel-M8974AAAAANLYA31050148/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/  CFLAGS_MODULE=-fno-pic modules


adb forward tcp:8080 tcp:8080

adb shell am dumpheap 9800  /storage/sdcard0/123.hprof


adb shell "echo 1 > /sys/class/kgsl/kgsl-3d0/pwrnap"
adb shell "echo 0 > /sys/class/kgsl/kgsl-3d0/pwrnap"

adb shell "echo performance > sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor" GPU为performance

adb shell "echo ondemand > /sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor"

在/system/build.prop里面添加

debug.mdpcomp.mixedmode.disable=1

debug.mdpcomp.logs=1

耗时的函数在mdss_mdp_overlay_kickoff 里面。


adb shell stop thermald

adb shell stop mpdecision

adb shell "echo 1 > /sys/devices/system/cpu/cpu0/online"

adb shell "echo 1 > /sys/devices/system/cpu/cpu1/online"

adb shell "echo 1 > /sys/devices/system/cpu/cpu2/online"

adb shell "echo 1 > /sys/devices/system/cpu/cpu3/online"

adb shell "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

adb shell "echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor"

adb shell "echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor"

adb shell "echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"

adb shell cat /sys/kernel/debug/tracing/available_events
adb shell cat /sys/kernel/debug/tracing/available_events | grep kgsl

mount -rw -o remount /system

adb shell "cat /sys/kernel/debug/clk/bimc_clk/rate"

find ./* -name ".svn" | xargs -exec rm -rif {}

man -k dtrace

sudo dtrace  -s py_calldist.d -c  sdk/platform-tools/systrace/systrace.py

sudo dtrace -s py_cputime.d  -c "python sdk/platform-tools/systrace/systrace.py"


find . -name "*.java" | xargs grep -rni "sdcard"  |tee  ~/logcat

adb shell am profile com.example.android start  /sdcard/example.trace

adb shell am   profile com.example.android stop

adb pull /sdcard/example.trace,再用eclipse打开

python systrace.py  --app=com.taobao.taobao gfx view am wm res dalvik hal webview  -o ojl.html

 adb shell strace  -f -t -p 21627
 adb shell debuggerd -b <pid> 
 adb shell cat /proc/<pid>/status
 adb shell cat /data/system/packages.xml


In your DDMS configuration file (e.g. ~/.android/ddms.cfg on Linux), add "native=true". This enables the Native Heap tab. 
Next, enable native heap allocation tracking on the device, and restart the app framework: 
% adb shell setprop libc.debug.malloc 1 
% adb shell stop 
% adb shell start 

 Trace.beginSection("ContentView");
Log.d("ojl", "trace");
setContentView(R.layout.cart3);

Trace.endSection();



  adb shell "tcpdump -n -s 0 -w - | nc -l -p 12345"


import android.os.Debug;

Log.d(TAG, "start method tracing");

Debug.startMethodTracing("cool", 20*1024*1024);



Log.d(TAG, "stop methond tracing");

Debug.stopMethodTracing();


Log.d("ojl", "ItemDownloader before priority = " + Process.getThreadPriority(Process.myTid()));
//Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND-4);  
//Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND-10); 
//Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT+1);
//Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT

//+(Process.THREAD_PRIORITY_BACKGROUND - Process.THREAD_PRIORITY_DEFAULT)/2);
//Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND+Process.THREAD_PRIORITY_MORE_FAVORABLE); 


import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
    private WakeLock wakeLock;  
private LocationManager locationManager; 


PowerManager pm = (PowerManager) getSystemService(this.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getCanonicalName());
wakeLock.acquire();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
   Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);


编译gator.ko
make -C kernelpath  M=`pwd` ARCH=arm
adb forward tcp:8080 tcp:8080
adb shell setenforce 0


<7>[  855.028505] SELinux: initialized (dev gatorfs, type gatorfs), not configured for labeling
<5>[  855.029024] type=1400 audit(1406342819.348:241): avc:  denied  { mount } for  pid=2347 comm="gatord-main" name="/" dev="gatorfs" ino=13742 scontext=u:r:shell:s0 tcontext=u:object_r:unlabeled:s0 tclass=filesystem
setenforce 0


new Thread() {
            public void run() {
                try {
                    sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Log.d("myException","xxxxxxxxxxxxxxxxxx");
                throw new RuntimeException("xxxxxxxxxxxxxxxxx");
            }
        }.start();  


Linux相关:

awk ‘{print $5}‘ |awk ‘{sum += $5};END{print sum}‘ test 计算某一列的和

du -h --max-depth=1 ./ 计算文件夹及文件的大小

知道指定后缀名的文件总个数命令: 

find . -name "*.cpp" | wc -l 

知道一个目录下代码总行数以及单个文件行数: 

find . -name "*.h" | xargs wc -l 

find . -name "*.c" | xargs grep ‘^.‘ | wc -l    //不包括空白行

find <要查找的路径> -name .svn |xargs rm -rf 

sudo find / -name "*opencv*" -exec rm -i {} \;

ssh oujunli@192.168.2.3

scp oujunli@192.168.2.3:/home/ojl/tmpfile  ./

fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/9.1-RELEASE/src.txz

sudo apt-get build-dep gedit ,这样基本上你开发gtk+的库都会被安装上.

provider:

dtrace -l|grep -v "PROVIDER"|awk ‘{print $2}‘|sort -u

dtrace -l -P provider

provider:module

dtrace -ln ‘fbt:::‘ | awk ‘{ print $2":"$3 }‘ | sort -u

sudo dtrace -n ‘syscall:::entry { @[stack(), ustack()] = count(); }‘ -c ‘./ls1 .‘
sudo dtrace -Fn ‘syscall::: { }‘ -c ‘./shell1‘

rsync --delete-before -a -H -v --progress --stats /tmp src/

sudo stap -p2 -e ‘probe kernel.function("*") {}‘ 2>&1 | grep ^kernel.fun

echo `cat /proc/slabinfo|awk ‘BEGIN{sum=0}{sum=sum+$3*$4;}END{print sum/1024/1024}‘` MB

find . -name ‘*.cpp‘ -print0 | xargs -0 perl -pi -e ‘s/ALOGV/ALOGD/g‘
find . -name "*.c" -print0 | xargs -0 sed -i ‘s/ALOGV/ALOGD/g

ls |xargs realpath |tee ../basic.name 

valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all  ./test-sdk

valgrind --tool=memcheck --leak-check=full --error-limit=no  --show-leak-kinds=all --dsymutil=yes  --log-file=logcat.txt --gen-suppressions=no -v ./Test

解:
jar xvf rt.jar
压:
jar cvf rt.jar rt

mvn dependency:tree
mvn eclipse:eclipse

git log -p --author="悟嗔"


  adb shell "echo function > /sys/kernel/debug/tracing/current_tracer"
  adb shell "echo 1846 > /sys/kernel/debug/tracing/set_ftrace_pid"
  adb shell "echo 1 > /sys/kernel/debug/tracing/tracing_enabled"
  adb shell cat /sys/kernel/debug/tracing/trace
  adb shell "echo nop > /sys/kernel/debug/tracing/current_tracer" 
  adb shell "echo 0 > /sys/kernel/debug/tracing/tracing_enabled"
  adb shell "echo 1 > /proc/sys/kernel/ftrace_dump_on_oops"

grep CONFIG_UPROBES /boot/config-`uname -r`
If uprobes is integrated, the output of this command is as follows:
CONFIG_UPROBES=y
If you are running a kernel prior to version 3.5, SystemTap automatically builds the uprobes module. However, you also need the utrace kernel extensions required by the SystemTap user-space probing to track various user-space events. More details about the utrace infrastructure are available at http://sourceware.org/systemtap/wiki/utrace. To determine whether the currently running Linux kernel provides the needed utrace support, type the following at a shell prompt:
grep CONFIG_UTRACE /boot/config-`uname -r`
If the Linux kernel supports user-space probing, the command produces the following output:
CONFIG_UTRACE=y


openindiana相关:

pkg serache -pr package // 查找包

pkg install package //安装包

pkgin -y update   //更新数据
pkg -y install pacage //安装包


VIM相关:

1、删除文本中的^M

问题描述:对于换行,window下用回车换行(0A0D)来表示,Linux下是回车(0A)来表示。这样,将window上的文件拷到Unix上用时,总会有个^M.请写个用在unix下的过滤windows文件的换行符(0D)的shell或c程序。

· 使用命令:cat filename1 | tr -d "^V^M" > newfile;

· 使用命令:sed -e "s/^V^M//" filename > outputfilename。需要注意的是在1、2两种方法中,^V和^M指的是Ctrl+V和Ctrl+M。你必须要手工进行输入,而不是粘贴。

· 在vi中处理:首先使用vi打开文件,然后按ESC键,接着输入命令:%s/^V^M//。

· :%s/^M$//g

如果上述方法无用,则正确的解决办法是:

· tr -d "\r" < src >dest

· tr -d "\015" dest

· strings A>B


""""""""""""""""""""""""""""""

" Tag list (ctags)

""""""""""""""""""""""""""""""

let Tlist_Ctags_Cmd = ‘/usr/bin/ctags‘

let Tlist_Show_One_File = 1            

let Tlist_Exit_OnlyWindow = 1          

let Tlist_Use_Right_Window = 1     

"let Tlist_Use_Left_Window = 1

let Tlist_Sort_Type = ‘name‘

let Tlist_Show_Menu = 1

let Tlist_Auto_Open = 1

nmap <silent> <F8> :TlistToggle<CR><CR>

2、生成cscope和ctags

  find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.java" -o -name "*.S" > cscope.files && cscope -Rbqk -i cscope.files&&ctags -R

  find . -path "./framework/*" -a -prune -o除去framework目录。

自动加载cscope文件,在.vimrc中添加:

if has("cscope")

set csprg=/usr/bin/cscope

set csto=1

set cst

set nocsverb

" add any database in current directory

if filereadable("cscope.out")

cs add cscope.out

endif

set csverb

endif


如果你是Python程序员,推荐http://t.cn/z84bJPg 。大名鼎鼎的移动支付公司 Square,最近将他们技术团队使用的 Vim 配置文件 Maximum Awesome 开源了,Vim 党们可以关注下。http://t.cn/z8UQPFW GitHub 地址:http://t.cn/z84w8ht

常用命令汇总

标签:adb   shell   命令   常用命令   

原文地址:http://blog.csdn.net/vincent20111024/article/details/43988255

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!