一些常用命令记录.md 2.0 KB


title: 一些常用命令记录 tags:

  • raspberrypi
  • 常用命令 id: '135' categories:
    • Raspberry Pi

      date: 2020-06-02 15:40:37

      sudo apt-cache search ifconfig
      sudo fdisk -l
      mount /dev/sda1 /mnt/u/
      
      aria2c --conf-path=/mnt/a/aria2c.conf
      ctrl+z
      bg
      disown
      前台 fg
      
      nohup command &
      
      sync
      umount /mnt/u/
      shutdowm -h now
      
      ssh-keygen -R xxx.xxx.xxx.xxx
      
      cd ~/BaiduPCS-Go-3.7.0-linux-arm/
      nohup sudo ./BaiduPCS-Go web --access &
      tail -fn 50 nohup.out
      cp /dev/null nohup.out
      
      先cd 到对应的文件夹,不要有random文件(夹),然后注意用全,不能用.和~
      ln -s /var/www/html/wp-content/themes/Sakura/manifest/gallary random
      

你可以在来启动nohup命令时,用追加模式来指定。
比如一般的命令是:
nohup /opt/aa.sh > aa.log 2>&1 &
追加模式是:
nohup /opt/aa.sh >> aa.log 2>&1 &
也就是多了一个右尖括号。
最后 cat /dev/null > aa.log 就可以清除aa.log的内容,包括aa.log文件大小也重置了。
这种方法用于动态清除日志,优点是不需要停服务

#!/bin/bash
cd BaiduPCS-Go-3.7.0-linux-arm/
killall BaiduPCS-Go
cp /dev/null nohup.out
nohup sudo ./BaiduPCS-Go web --access &
# 创建后台启动模版
nano /etc/systemd/system/aria2.service

[Unit]
Description=aria2c
After=network.target

[Service]
ExecStart=/usr/bin/aria2c --conf-path=/media/d/aria2c.conf

[Install]
WantedBy=multi-user.target

# 启动测试
systemctl start aria2
# 查看启动状态
systemctl status aria2
# 开机自启
systemctl enable aria2
nano /etc/init.d/ossfs

#! /bin/bash
#
# ossfs      Automount Aliyun OSS Bucket in the specified direcotry.
#
# chkconfig: 2345 90 10
# description: Activates/Deactivates ossfs configured to start at boot time.
ossfs limourfile /media/oss -ourl=http://oss-cn-shanghai-internal.aliyuncs.com -o allow_other

chmod a+x /etc/init.d/ossfs
chkconfig ossfs on