0网络相关
ssh 反向代理
ssh -fCNR 10000:localhost:22 userB@B.B.B.B
B.B.B.B是一个外网机器B的IP
ssh -p 10000 userA@localhost
在机器B,ssh到机器A
防火墙
- 查看防火墙服务状态
systemctl status firewalld - 查询端口是否开放
firewall-cmd --query-port=8080/tcp - 开放80端口
firewall-cmd --permanent --add-port=80/tcp - 移除端口
firewall-cmd --permanent --remove-port=8080/tcp - 重载防火墙使配置生效
firewall-cmd --reload
git
(取消)设置git代理,注意设置的前提是以及在系统中设置好了代理
git config --global http.proxy http://127.0.0.1:8889
git config --global http.proxy https://127.0.0.1:8889
git config --global http.proxy 'socks5://127.0.0.1:1089'
git config --global https.proxy 'socks5://127.0.0.1:1089'
#git config --global --unset http.proxy
git config --global core.editor vim
下载子模组
git submodule update --init --recursive
统计代码
git log --author="zhaojunchao@loongson.cn" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %sn", add, subs, loc }' -
代码格式化
// 格式化最新的commit,并直接在原文件上修改
git diff -U0 HEAD^ | clang-format-diff.py -i -p1
换行符转换
git config --global core.autocrlf input
硬件相关的
iic
i2cdetect -l 列出系统中有的i2c总线
i2cdetect -y 1 扫描i2c 1号总线上的设备
i2cdump -y 1 0x50 dump出1号总线上地址为0x50设备的寄存器内容
pci
lspci 查看有那些设备
lspci -s 01:00.0 -vvv 查看指定设备的详细信息
硬盘健康检测
sudo yum install smartmontools
sudo smartctl -a /dev/sda
dmidecode
dmidecode 查看系统的硬件信息
dmidecode --type memory 查看内存硬件信息
调整cpu频率
蓝牙
apt install bluez
bluetoothctl
power on
scan le
connect [MAC]
menu gatt
内核相关的
- 把内核模块编译安装到制定目录
make modules_install INSTALL_MOD_PATH=./mod_install - 制作initramfs
dracut --omit-drivers “stmmac_pci stmmac” --add-drivers “virtio_pci” --force /boot/initramfs-4.19.161.img 4.19.161
制作initramfs时驱动使用/lib/modules/4.19.161/里的,并且额外添加virtio_pci.ko ,不添加stmmac_pci.ko 和stmmac.ko - 清内存缓存 echo 3 > /proc/sys/vm/drop_caches
运维
-
root以某用户身份运行程序
runuser - [用户名] -c “要运行的命令”
-s 可以指定用那个shell运行 -
挂载img文件
- 先使用fdisk查看img文件信息
fdisk -l [文件名]
offset为8192个扇区,一个扇区512B,8192*512=4194304
2.使用mount挂载
sudo mount -o loop,offset=4194304 Armbian_21.05.0-trunk_Nanopik1plus_buster_current_5.10.21_minimal.img ~/mnt
- 先使用fdisk查看img文件信息
-
virtbox 无法添加USB设备解决
sudo usermod -aG vboxusers -
查看dd 命令进度
watch -n 5 killall -USR1 dd -
产生指定长度的随机字符串
openssl rand -base64 8pwgen
mkpasswd -l 8
-
passwd不检查密码强度
修改/etc/pam.d/common-password 字段requisite -
手动对时
ntpdate asia.pool.ntp.org -
soft mount
mount -t nfs -o rw,soft,timeo=30,retry=3 {}
-
关闭或开启u盘自动挂载
systemctl start/stop udisks2.service
-
软件版本管理
update-alternatives --display python3 sudo update-alternatives --config python3
系统监视
- iotop
- htop
- nethogs
- iftop
编程
-
生成 compile_commands.json
ninja -t compdb -x c_COMPILER cpp_COMPILER > compile_commands.json
-
编译debug
CFLAGS="-O0 -g3 -ggdb" CXXFLAGS="-O0 -g3 -ggdb"
docker
runlike 命令可以查看容器的运行命令
文本编辑
-
向文件头部插入信息
sed -i '1r ./cpy.txt' ../hello.S
-
将文本编码格式转换为utf8
find -name "*.c" | xargs enca -x utf-8