30 篇文章带有标签 “Command”

命令chown

更改文件所有者和组

    chown [OPTION]... [OWNER][:[GROUP]] FILE...

Apache HTTP Server实践

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 8081
......
......
  • /etc/apache2/sites-enabled/000-default.conf
sudo nano /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:8081>
......
......
</VirtualHost>
  • 重启服务
sudo systemctl restart apache2

命令ffmpeg

  • 生成gif(低质量) -pix_fmt(像素格式) -s(设置帧大小WxH)
ffmpeg -y -i input.mp4 -pix_fmt rgb8 -r 10 -s 320x240 output.gif
ffmpeg -y -i input.mp4 -pix_fmt rgb8 -r 10 -vf 'scale=320:-1' output.gif
  • 生成gif(高质量) -ss(开始时间偏移) -t(持续时间)
ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
ffmpeg -y -ss 5 -t 5 -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
  • 每秒抽取一张图片 -r(设置帧速率)
ffmpeg -i input.mp4 -r 1 -s 1024x768 -f image2 input-%03d.jpeg

命令history

  • 持久化设置,可以修改配置文件:.bash_profile 或 .bashrc。执行source命令后,设置生效。你也可以退出后重新登录。
$ nano .bashrc
export HISTCONTROL=ignorespace
$ source .bashrc

命令find

  • 以详细信息显示 /var/log 目录下最近 24小时内修改的文件
$ find /var/log -mtime 0 -ls
 33575669      4 drwxr-xr-x  15  root     root         4096 7月 29 06:33 /var/log
 34131780    164 -rw-------   1  root     root       166061 7月 29 10:20 /var/log/messages
  • 显示 /var/log 目录下最近 [0 - 24小时] 修改的文件
find /var/log -mtime -1
  • 显示 /var/log 目录下最近 [24 - 48小时] 修改的文件
find /var/log -mtime 1
  • 显示 /var/log 目录下最近 [48 - ] 修改的文件
find /var/log -mtime +1
  • 以详细信息显示当前目录下超过 40M的文件
$ find . -size +40M -ls
 17180574  42480 -rwxr-xr-x   1  root     root      43499520 3月 11  2020 ./kubectl
  • 显示当前目录下超过 40M的文件,通过 ls 命令来显示结果。
$ find . -size +40M -exec ls -lh {} \;
-rwxr-xr-x 1 root root 42M 3月  11 2020 ./kubectl

命令grep

  • 忽略字母大小写(-i)
grep -i 'text' hello.txt
  • 搜索多个文件
grep 'text' hello.txt hi.txt
  • 搜索当前目录下所有文件
grep 'text' *
  • 搜索当前目录(包含子目录 -R)下所有文件
grep -R 'text' *
  • 搜索 pip 配置文件的路径(增加过滤)
find ~ -name pip* | xargs -i grep "index-url" {} --color -nH
/home/lnsoft/.config/pip/pip.conf:2:index-url = https://mirrors.aliyun.com/pypi/simple/
  • 只匹配字符串,不使用正则表达式。
find . | grep -F .run
  • 显示当前目录下的文件
ll | grep '^-'
  • 显示当前目录下的所有目录及子目录(遍历)
ll -R | grep '^d'
  • 统计目录数
ll | grep '^d' | wc -l

图像格式转换、尺寸调整

  • macOS
brew install imagemagick
  • 按照指定高等比调整
convert test.jpg -resize x640 test.jpg
  • 按照指定宽高等比调整
convert test.jpg -resize 640x640 test.jpg
  • 按照指定宽高调整
convert test.jpg -resize 640x640! test.jpg
  • 方法2
find . -name '*.png' -exec convert {} -resize 640x640 {} \;