30 篇文章带有标签 “Command”

WebP 格式的命令工具

webp 是一个官方工具包,它不是单个软件,而是一整套处理 WebP 格式的命令工具集合。

brew install webp
# 有损(推荐,长截图用)
cwebp -q 80 input.png -o output.webp
# 无损(画质完全不变,体积稍大)
cwebp -lossless input.png -o output.webp
dwebp input.webp -o output.png

命令 alias

zsh 中使用单引号('),不对特殊符号进行解析,使用双引号(")会对特殊符号进行解析,如:$

docker rmi none

alias docker.rmi.none='docker rmi --force $(docker images -q --filter "dangling=true")'

通过命令使用 ChatGPT

  • Ubuntu
sudo apt install moreutils
chatgpt install
Install mode: Log in to ChatGPT in the browser that pops up, and click
through all the dialogs, etc. Once that is achieved, exit and restart
this program without the 'install' parameter.


    Provide a prompt for ChatGPT, or type /help or ? to list commands.                                                        

1> /quit
GoodBye!

命令 nc

  1. 发送 HTTP 请求。
curl http://ip:port/
GET /?name=wjj HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: curl/7.61.1
Accept: */*
POST /users_by_json HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: curl/7.61.1
Accept: */*
Content-Type: application/json
Content-Length: 36

{
    "name": "wjj",
    "age": 40
}

命令tr

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            126G     0  126G   0% /dev
tmpfs            26G  4.0M   26G   1% /run
/dev/sda2       548G   50G  471G  10% /
tmpfs           126G     0  126G   0% /sys/fs/cgroup
/dev/sda1       511M  7.9M  504M   2% /boot/efi
/dev/sdb1       2.0T  4.7G  1.9T   1% /data
$ df -h | tr a-z A-Z

命令man help info

  • man man
......
    下表显示了手册的 章节 号及其包含的手册页类型。

    1   可执行程序或 shell 命令
    2   系统调用(内核提供的函数)
    3   库调用(程序库中的函数)
    4   特殊文件(通常位于 /dev)
    5   文件格式和规范,如 /etc/passwd
    6   游戏
    7   杂项(包括宏包和规范,如 man(7),groff(7))
    8   系统管理命令(通常只针对 root 用户)
    9   内核例程 [非标准]
......
  • 查看指定章节
man 7 man
man man.7
  • 寻找所有匹配(-a, --all 寻找所有匹配的手册页)
man -a passwd
--Man-- 下一页: passwd(5) [ 查看 (return) | 跳过 (Ctrl-D) | 退出 (Ctrl-C) ]
  • 内部命令使用 help
help cd
cd --help
  • 外部命令使用 help
ls --help
info cd

命令base64

  • 解码(正确,这里之所以正确是因为base64过滤了。)
$ echo 'YWRtaW4=' | base64 -d
admin[username@hostname ~]$
  • 编码(错误,这是因为 echo 输出字符后会在后面再输出换行符。)
$ echo 'admin' | base64
YWRtaW4K
  • 方法一:使用 printf 命令。
$ printf 'admin' | base64
YWRtaW4=
  • 方法二:可以通过参数 -n 告诉 echo 不输出换行符。
$ echo -n 'admin' | base64
YWRtaW4=

方法三:可以通过参数 -e 告诉 echo 启用反斜杠转义的解释。

命令brew

  • 方法2:替换brew源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
brew update

命令tar

    -c, --create Create a new archive.  Arguments supply the names of the files to be archived.
    -x, --extract, --get Extract files from an archive.
    -z, --gzip, --gunzip, --ungzip Filter the archive through gzip(1).
    -j, --bzip2 Filter the archive through bzip2(1).
    -f, --file=ARCHIVE Use archive file or device ARCHIVE.  If this option is not given, tar will first examine the environment variable `TAPE'.  If it is set, its value will be used as the archive  name.   Otherwise, tar will assume the compiled-in default.
    -t, --list List the contents of an archive.
    -v, --verbose Verbosely list files processed.

命令zip

排除所有的 yaml 文件

zip -r yolov5.zip yolov5/ -x "*yolo*.yaml"

只查看文件名 $ zipinfo -1 yolov5.zip yolov5/ yolov5/hubconf.py yolov5/tutorial.ipynb yolov5/Dockerfile yolov5/README.md yolov5/.dockerignore yolov5/models/ yolov5/models/common.py yolov5/models/export.py yolov5/models/yolov5s.yaml yolov5/models/yolo.py yolov5/models/init.py yolov5/models/experimental.py yolov5/models/yolov5m.yaml yolov5/models/yolov5l.yaml yolov5/models/yolov5x.yaml yolov5/LICENSE yolov5/.gitignore yolov5/test.py yolov5/train.py yolov5/weights/ yolov5/weights/download_weights.sh yolov5/requirements.

命令du

du - 估计文件空间使用量

    -s, --summarize display only a total for each argument
    -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)

命令ln

在文件之间建立链接

    ln [OPTION]... [-T] TARGET LINK_NAME
    ln [OPTION]... TARGET
    ln [OPTION]... TARGET... DIRECTORY
    ln [OPTION]... -t DIRECTORY TARGET...
  1. rm
rm /var/www/ubuntu