public:it:linux:start

Linux

  • init.d 脚本编写参考 /etc/init.d/skeleton

    使用start-stop-daemon启动nodejs保存输出的方法:

    start-stop-daemon --start  --quiet  \
    --pidfile $PIDFILE -b -m --startas \
    /bin/bash -- -c "exec ${NODE_PATH} ${NODE_SCRIPT} >> ${LOG_PATH} 2>&1"
  • nohup
  • watch
  • /etc/ld.so.conf 动态链接搜索路径设置, 改完后需要 sudo ldconfig
  • ldconfig -p 列举动态链接库列表
  • Socat, simulate a pair of serial ports: socat -d -d PTY PTY
  • 使用 bash 串口通信
    # 设置波特率
    ## 查看当前信息
    $ stty -F ttyO1
    ## 设置波特率
    $ stty -F ttyO1 38400
    # 监听
    $ od -t x1 ttyO1
    # 写
    $ echo hello > ttyO1
    # 或者用 screen 读写
    $ screen tty01 38400
  • which : 查看命令关联之文件(或link)
  • locate : 该命令需要索引数据库作为支撑,在 Ubuntu 中数据库文件位于 /var/cache/locate/locatedb。一般来说,这个数据库文件每天通过 cron 自动更新。可执行 sudo updatedb 来手动更新。 假如想要查找一个名为 linux.html 的文件,可以执行:locate linux.html。locate 选项 -r即可使用正则表达式。具体 man locate 查看说明.
  • find : 一般使用方法:find 位置 -name 文件名称例如 find / -name linux.html。find 也可以根据文件大小-size n -atime n 来搜索文件。 此外,find支持使用正则表达式,只需指定 -regex . 具体可以 man find 查看说明.
  • 查看:od -x <file>, 具体man od;
  • 小的二进制文件可用 vim 编辑:vim -b <file>打开后,输入命令 :%!xxd
  • 大内容二进制文件修改部分: printf “\x41\x41” | dd of=big_binary.dat bs=1 count=2 conv=notrunc seek=888888
  • public/it/linux/start.txt
  • 最后更改: 2023/12/25 15:42
  • oakfire