登录终端就配置变量环境
sh环境切到bash, 解决按键对应问题和环境配色问题
sudo vi /etc/passwd
#xts:x:1001:0::/home/xts:/bin/sh
xts:x:1001:0::/home/xts:/bin/bash
vi ~/.bashrc
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
vi .bash_profile
source .bashrc
配色
history (.bash_profile)
export PATH=$PATH:$HOME/bin
alias hfix='history -n && history | sort -k2 -k1nr | uniq -f1 | sort -n | cut -c8- > ~/.tmp$$ && history -c && history -r ~/.tmp$$ && history -w && rm ~/.tmp$$'
HISTCONTROL=ignorespace:erasedups
shopt -s histappend
shopt -s extglob
PROMPT_COMMAND="hfix; $PROMPT_COMMAND"
HISTSIZE=10000
HISTFILESIZE=20000
alias ..="cd .."
alias ..2="cd ../.."
alias ..3="cd ../../.."
alias ..4="cd ../../../.."
alias ..5="cd ../../../../.."
alias ..6="cd ../../../../../.."
alias ..7="cd ../../../../../../.."
alias ..8="cd ../../../../../../../.."
alias ..9="cd ../../../../../../../../.."
alias ..10="cd ../../../../../../../../../.."
1.vim
默认设置行号 set number
或者新建~/.vimrc 写入
set number
2.便捷设置
根据已输入命令上下翻输入历史记录
在~/.inputrc 写入
"\e[A": history-search-backward
"\e[B": history-search-forward
输入路径忽略大小写
set completion-ignore-case on
home/end配置
"\e[1~": beginning-of-line
"\e[4~": end-of-line
4.linux基础命令
1.uname -a # 查看内核/操作系统/CPU信息的linux系统信息
2.head -n l /etc/issue # 查看操作系统版本
3.cat /proc/cpuinfo # 查看CPU信息
4.hostname # 查看计算机名的linux系统信息命令
5.lspci -tv # 列出所有PCI设备
6.lsusb -tv # 列出所有USB设备的linux系统信息命令
7.lsmod # 列出加载的内核模块
8.env # 查看环境变量资源
9.free -m # 查看内存使用量和交换区使用量
10.df -h # 查看各分区使用情况
11.du -sh # 查看指定目录的大小
12.grep MemTotal /proc/meminfo # 查看内存总量
13.grep MemFree /proc/meminfo # 查看空闲内存量
14.uptime # 查看系统运行时间、用户数、负载
15.cat /proc/loadavg # 查看系统负载磁盘和分区
16.mount | column -t # 查看挂接的分区状态
17.fdisk -l # 查看所有分区
18.swapon -s # 查看所有交换分区
19.hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)
20.dmesg | grep IDE # 查看启动时IDE设备检测状况网络
21.ifconfig # 查看所有网络接口的属性
22.iptables -L # 查看防火墙设置
23.route -n # 查看路由表
24.netstat -lntp # 查看所有监听端口
25.netstat -antp # 查看所有已经建立的连接
26.netstat -s # 查看网络统计信息进程
27.ps -ef # 查看所有进程
28.top # 实时显示进程状态用户
29.w # 查看活动用户
30.id # 查看指定用户信息
31.last # 查看用户登录日志
32.cut -d: -f1 /etc/passwd # 查看系统所有用户
33.cut -d: -f1 /etc/group # 查看系统所有组
34.crontab -l # 查看当前用户的计划任务服务
35.chkconfig –list # 列出所有系统服务
36.chkconfig –list | grep on # 列出所有启动的系统服务程序
37.rpm -qa # 查看所有安装的软件包
38.cat /proc/cpuinfo :查看CPU相关参数的linux系统命令
39.cat /proc/partitions :查看linux硬盘和分区信息的系统信息命令
40.cat /proc/meminfo :查看linux系统内存信息的linux系统命令
41.cat /proc/version :查看版本,类似uname -r
42.cat /proc/ioports :查看设备io端口
43.cat /proc/interrupts :查看中断
44.cat /proc/pci :查看pci设备的信息
cat /proc/swaps :查看所有swap分区的信息
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 1 > /sys/devices/system/cpu/cpu4/online"
adb shell "echo 1 > /sys/devices/system/cpu/cpu5/online"
adb shell "echo 1 > /sys/devices/system/cpu/cpu6/online"
adb shell "echo 1 > /sys/devices/system/cpu/cpu7/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 "echo performance > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor"
adb shell "echo performance > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor"
adb shell "echo performance > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor"
adb shell "echo performance > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor"
git push origin HEAD:refs/for/master
vi ~/.gitconfig
[user]
name = name
email = name@xxx.com
[color]
ui = auto
[branch]
autosetuprebase = always
[alias]
co = checkout
st = status
br = branch
cm = commit
[url "ssh://name@xx.xx.xx"]
pushInsteadOf = ssh://name@xx.xx.xx
[url "ssh://boxing-master"]
pushInsteadOf = ssh://boxing
[merge]
tool = vimdiff
[commit]
template = ~/.gitmessage
[core]
editor = vim
wsl 识别不到adb
sudo ln -s ~/bin/adb.exe ~/bin/adb
或者在~/.bashrc 增加(先定义PATH)
sudo ln -s ~/bin/adb.exe ~/bin/adb
adb: no permissions (user xx is not in the plugdev group);
sudo vim /etc/udev/rules.d/android.rules
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0666"
INSTALL_FAILED_VERIFICATION_FAILURE
adb shell settings put global verifier_verify_adb_installs 0
debug命令
查看进程加载so:
lsof |grep pid
查看so位置
cat /proc/1690/maps | grep xxx.so
查看so中的strings
adb shell "strings /system/lib/libsfplugin_ccodec.so |grep 'setting up'"
repo 切分支
查看可切换的分支
cd .repo/manifests
git branch -a | cut -d / -f 3
repo init -b android-13.0.0_r7
repo sync
repo start android-13.0.0_r7 --all
addr2line/objdump
(https://blog.csdn.net/afei__/article/details/81181827)
工具位置在ndk中
root@000:/mnt/d/ffmpeg/source#
find -name aarch64-linux-android-addr2line
./android-ndk-r20b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/
aarch64-linux-android-addr2line
aarch64-linux-android-objdump
aarch64-linux-android-addr2line -C -f -e xx.so 1f1f1f1f
eg.
aarch64-linux-android-addr2line -C -f -e ./out/target/product/raven/symbols/system/lib64/libffmpegextractor.so 00000000000045d4
arm-linux-androideabi-objdump -d xx.so > symbol.txt
./prebuilts/clang/host/linux-x86/llvm-binutils-stable/llvm-addr2line -C -f -e ./out/target/product/qssi/symbols/system_ext/lib64/extractors/libffmpegextractor.so 0c054
kill media
adb shell "ps -A|egrep 'mediaex|mediaserver|mediacodec' && pkill -u mediaex && pkill -u mediacodec && pkill -u media && echo '\n' && ps -A|egrep 'mediaex|mediaserver|mediacodec' "
java
打印文件+方法+行号
Log.d("tag",Thread.currentThread().getStackTrace()[2].getFileName()+":"+Thread.currentThread().getStackTrace()[2].getMethodName()+":"+Thread.currentThread().getStackTrace()[2].getLineNumber());
查找文件并copy
find . -iname "*black_48.png" -type f -exec cp {} ./../vinter3 \;
find . -iname "*black_48.png" -type f | xargs -I {} cp {} ./../vinter3
找到app的安装路径
adb shell "pm list package -f |grep ijk"
#查看activity
adb shell am monitor
#清理app存储
adb shell pm clear com.android.settings
反汇编ijk
aarch64-linux-android-addr2line -C -f -e ./ijkplayer/ijkplayer-arm64/src/main/obj/local/arm64-v8a/libijkplayer.so 25ef4
sed 查找替换
去掉注释// #define LOG_NDEBUG 0 //#define LOG_NDEBUG 0
sed -i 's/\/\/.#define LOG_NDEBUG 0/\#define LOG_NDEBUG 0/g' `grep LOG_NDEBUG -rl ./`
//删文件名中空格
find . -name "* *"| while read name;do na=$(echo $name | tr -d ' ');mv "$name" $na;done;
find . -name "*-*"| while read name;do na=$(echo $name | sed -i 's/xxx.*\-//g');mv "$name" $na ;done;
android cpp callstack
1.添加头文件:
#include <utils/CallStack.h>
2.在需要打印函数调用栈的函数中添加如下代码:
android::CallStack stack;
stack.update();
stack.log("stack logtag"); //后面字符串表示log中的包含字符,在查找时会比较方便
3.在函数文件对应的Android.mk中:
LOCAL_SHARED_LIBRARIES := libutils \ 一般都会有
libutilscallstack \ 还需要加上这个,否则编译不过
添加systrace tag:JAVA
import android.os.Trace;
Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, "dequeueInputBuffer");
Trace.traceEnd(Trace.TRACE_TAG_ALWAYS);
文件分割
split -b 200m a.txt -d -a 4 b_
wsl adb 识别不到:
将window下的adb.exe的path配置windows的环境变量中(或者也配置到~/.bashrc中 export PATH=$PATH:/mnt/platform-tools/), 然后 ~/.bashrc 配置alias adb=“adb.exe”, 即可
young@XJWH00707:~/platform-tools$ adb version
Android Debug Bridge version 1.0.41
Version 34.0.1-9680074
Installed as D:\vinter\7.tools\platform-tools_r34.0.1-windows.1.0.41_34.0.1-9680074\platform-tools\adb.exe
关闭打开echo 回显 linux && windows
stty -echo :关闭回显
stty echo :开启回显
echo off
echo on
目录链接(android 编译对ln -s 不支持)
#mount --bind src dst
sudo mount --bind /mnt/d/vinter/3.git/ffmpeg/ffmpeg4android ffmpeg4android
sudo umount ffmpeg4android
xshell启动wsl
#1、先删ssh,再安装ssh
sudo apt-get remove --purge openssh-server ## 先删ssh
sudo apt-get install openssh-server ## 在安装ssh
sudo rm /etc/ssh/ssh_config ## 删配置文件,让ssh服务自己想办法链接
sudo service ssh --full-restart
#2、修改配置文件
sudo vim /etc/ssh/sshd_config
Port 6666
ListenAddress 0.0.0.0
PasswordAuthentication yes
#3、重启ssh(每次重启wsl都要执行该语句)
sudo service ssh --full-restart
#4、重新生成host key
sudo dpkg-reconfigure openssh-server
#5、连接XShell
#主机127.0.0.1
#端口号6666
本地其他目录的git仓 链接到android repo大仓.
sudo mount --bind /mnt/d/vinter/3.git/ffmpeg/ffmpeg4android /mnt/e/code/tf10/vendor/xx/frameworks/media/ffmpeg4android
drmkey
adb shell WVStoreKeybox verify
Verify keybox
Check QTI licenses
QTI licenses: 898-898-no-exp-2574099444.pfm.inst
Result: 0x00000000 WVSKB_SUCCESS
tar多线程压缩
sudo apt install pigz
tar -cvf - dir1 dir2 dir3 | pigz -p 8 > output.tar.gz //8 threads, 不用-p 参数则是最大
tar -xzvf output.tar.gz
android.mk打印
$(warning "debug print $(var)")
隐藏光标
echo -e "\033[?25l"
显示光标
echo -e "\033[?25h"
获取app的版本
adb shell "pm dump com.test.hm | grep 'version'"
设置log
#include <android-base/logging.h>
//char value[PROPERTY_VALUE_MAX] = {0};
//property_get("vendor.media.video.dump", value, "0");
//int32_t propEnable = atoi(value);
//if (propEnable) {
// SetMinimumLogSeverity(base::VERBOSE);
//} else {
// SetMinimumLogSeverity(base::ERROR);
//}
//base::ScopedLogSeverity mScopedLogSeverity{base::VERBOSE};
//SetMinimumLogSeverity(base::ERROR);