由 CyanHall.com
创建于 2020-11-11,
上次更新:2021-01-08。
👉
如果有用请点赞。 如果想查询 Shell 命令每个参数的含义复制粘贴到 explainshell 查询。
👉
1. 更改默认的Shell
chsh -s /bin/zsh
2. 查看文件/目录的大小
du -sh [filePath/Directory]
3. 强制删除目录内的文件
rm -rf dir
# -f for force, -r for recursive
4. 查找具有特定模式的文件
find / -name filename.xx
5. 移除具有指定模式的文件
find . -name '*.pyc' -delete # remove all .pyc files from a project
6. 找到所有某名字的进程
ps aux | grep [name]
7. 关闭所有某名字的进程
kill $(ps aux | grep [name] | awk '{print $2}')
8. 实时查看日志
tail -f filename.log
9. 检查网络的连接性
nc -z -v [ip] [port]
10. 检查端口占用
sudo lsof -i:[port number]
11. 断电续传下载文件
wget -c [url]
12. 从远程服务器下载文件
scp -i ssh-key-file [user]@[ip]:remote/file/path local/file/path
13. 上传文件到远程服务器
scp -i ssh-key-file [file/to/send] [user]@[ip]:[dest/path]
14. 给脚步执行的权限
chmod +x ./script.sh
15. 生成新的SSH密钥文件
ssh-keygen -t rsa -C "remark"
16. 启动 SSH 客户端
eval `ssh-agent -s`
17. 限制 SSH 密钥文件的访问
chmod 400 [key-path]
18. 启用 SSH 密钥
ssh-add [key-path] # without .pub
19. 用SSH创建一个socks v5代理
ssh -i ssh-key-file -o IdentitiesOnly=yes [username]@[ip] -D 127.0.0.1:1007
20. Shell 循环
for i in `seq -w 000 3`;do echo test_"${i}";done
# Output:
# test_000
# test_001
# test_002
# test_003
21. macOS
say hello world
# list all langs
say -v '?'
# list all file format
say --file-format=?
say -v Ting-Ting -o test.aac hello world
更多