常用命令汇总

来源:互联网 发布:织里美萍软件电话 编辑:程序博客网 时间:2024/05/07 17:34

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

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 老公诈骗坐牢家人该怎么办 家人被拘留我该怎么办 车牌被偷了一个怎么办 车牌给人家偷了怎么办 收购了偷来的铝怎么办 员工自动离职后档案怎么办 辞职了老板不发工资怎么办 上班老板不发工资怎么办 逮捕后延长羁押期限怎么办手续 员工提出辞职公司不同意怎么办 员工提出辞职后即不来上班怎么办 打架把对方打成轻伤害怎么办 被刑拘了家人该怎么办 看守所在押人员检查出乙肝怎么办 孩子不写作业老师该怎么办 孩子老师向我表白该怎么办 幼儿园老师打孩子家长该怎么办 老师对孩子太苛刻该怎么办 孩子不敢上学怕老师该怎么办 学生上课迟到老师该怎么办 看守所转监狱不收怎么办 己判实刑有病看守所不收怎么办 判决书生效前看守所不收怎么办 法院判实刑看守所不收怎么办 派出所立案后送拘留所了怎么办 打架斗殴被关在看守所了怎么办 在看守所羁押期间患癌症怎么办 无法偿还借款拘留15天后怎么办 离婚起诉被告人被羁押怎么办 事实不清的案件怎么办 交通事故没时间去做笔录怎么办 偷东西被拘留家长该怎么办 在香港被拘留了怎么办 发票认证机卡了怎么办 交罚款的单子丢了怎么办 父亲行政拘留考警察政审不过怎么办 非法经营罪立案后不批刑拘怎么办 12分扣完了怎么办2018 驾驶证c1扣14分怎么办 车辆被扣12分怎么办 两个违章扣12分怎么办