这个仓库用于沉淀常用 Linux / Git / Python 命令 和日常脚本。
你提到希望能在 README 正文里直接 Ctrl + F 找到命令,因此本版把常用命令与脚本运行命令都集中到一个文档里(不需要再点进目录找)。
已完成一次物理重组:根目录脚本归档到
scripts/,杂项笔记归档到docs/notes/,其余功能目录保持不变。
scripts/python/PIL_draw.pyscripts/python/batch_move.pyscripts/python/convert_txt_format.pyscripts/python/csv_gen.pyscripts/python/delete_script.pyscripts/python/image_review.pyscripts/python/to_excel.pyscripts/python/visualization_from_txt.pyscripts/python/visualization_match_biaozhuTeam.py
calculate_ssim/calculate_headpose/
google_drive_downloader/
scripts/shell/run.shscripts/shell/copytxt.shscripts/shell/rename.shscripts/shell/doas-install.sh
docs/notes/MacOS.mddocs/notes/VS2019.mddocs/notes/docker_mysql.mddocs/notes/memory.mddocs/notes/latex.mddocs/notes/Interview_notes.mddocs/notes/review.mddocs/notes/test.mddocs/notes/pycharm-remote-jupyter-ipy-access.md
去重后保留一份,可直接复制。
sudo apt install gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
sudo update-alternatives --config gcc
sudo update-alternatives --config g++# 新分支开发并推送
git checkout -b new-feature-branch
git add .
git commit -m "your message"
git push origin new-feature-branch
# 查看分支
git branch
git branch -r
git branch -a
# 创建并切换分支
git checkout -b <branch>
# 切换已有分支
git checkout <branch>
# 推送分支
git push origin <branch>
# 删除本地分支
git branch -d <branch>
# 删除远程分支
git push origin :<branch>
# 拉取
git pull
git pull <repo_url> <branch>
# 一条命令 add+commit+push
git add . && git commit -m "update" && git push
# 清除索引缓存
git rm -r --cached .
# 强制同步远程(谨慎)
git fetch --all && git reset --hard origin/main && git pull
# 回滚一次提交(保留历史)
git revert HEAD
git push origin mastergit clone https://github.com/MitchellX/flash-attention.git
git remote add upstream https://github.com/Dao-AILab/flash-attention.git
git remote -v
git fetch upstream
git merge upstream/main
git push# Linux -> Windows(示例)
scp user@host:/path/file.tar e:
# Windows -> Linux(示例)
scp -rp e:\scpdata root@10.1.22.5:/root
# 远程到本地
scp -r user@host:/remote/path /local/path
# 本地到远程
scp -r /local/path user@host:/remote/path
# 指定端口
scp -P 7022 ./nyu_v2.zip user@host:/remote/path
# 多文件
scp index.css json.js root@192.168.1.104:/usr/local/nginx/html/webs
# 多目录(花括号)
scp -r root@192.168.1.104:/usr/local/nginx/html/webs/\{index,json\} ./
# rsync(排除文件)
rsync -rvz -e 'ssh -p 22' --exclude='*.model' dir/ host:/dir
# rsync(跳过已存在且旧文件)
rsync -aWPu local/ root@host:remote/# 系统版本
cat /etc/redhat-release
lsb_release -a
uname -a
rpm -q centos-release
# CPU
cat /proc/cpuinfo
# 磁盘
df -lh
du -lh
# GPU 监控
gpustat
watch -n 0.1 nvidia-smi
lspci | grep -i vga
# 查占用并释放 GPU
fuser -v /dev/nvidia*
nvidia-smi
kill -9 <pid>
# 指定 GPU
CUDA_VISIBLE_DEVICES=1 python your_file.py
CUDA_VISIBLE_DEVICES=0,1 python your_file.py
# tar 打包解压
tar -cvf data.tar /source
tar -xvf data.tar
tar -czvf data.tar.gz /source
tar -xzvf data.tar.gz
tar -cjvf data.tar.bz2 /source
tar -xjvf data.tar.bz2# 禁用代理
unset https_proxy
unset http_proxy
# 更新 apt 源
sudo apt-get update
# 环境变量(记得 source ~/.bashrc)
export PYTHONPATH=$PYTHONPATH:/your/path
# pip 国内源
pip install <pkg> -i https://pypi.tuna.tsinghua.edu.cn/simple
# conda 克隆环境
conda create -n BBB --clone AAA
conda create -n BBB --clone ~/path/to/env
# conda 新建 / 删除
conda create -n your_env_name python=3.10
conda remove -n your_env_name --all
# virtualenv
virtualenv --clear envs/test
source envs/test/bin/activate
deactivate# screen
yum install -y screen
screen
screen -S <name>
screen -ls
screen -r <name>
screen -d -r
screen -X -S <name> quit
# tmux
yum install -y tmux
tmux new -s <name>
tmux ls
tmux attach -t <name>
tmux attach -d -t <name>
tmux kill-session -t <name>
# 前后台
jobs -l
bg
fg
kill <pid># ipdb
python -m ipdb your_code.py
# python 侵入式调试
import ipdb; ipdb.set_trace()
# 通配符 mv
mv *.* ./1000/
mv 6???.* ./6000/
# basename 去前缀与后缀
basename /a/b/c.jpg
basename /a/b/c.jpg .jpg
# 文件夹不存在则创建(shell)
if [ ! -d "/myfolder" ]; then mkdir /myfolder; fipip3 install youtube-dl ffmpeg-python
youtube-dl <youtube_url> --merge-output-format mp4 -o /content/data/source_tmp.mp4
ffmpeg -y -i /content/data/source_tmp.mp4 -ss 00:01:40 -to 00:01:50 -r 25 /content/data/source.mp4这一节覆盖仓库里可执行的
.py/.sh。
一部分脚本是“硬编码路径”风格(没有 argparse),命令可直接跑,但通常需要先改脚本内路径变量。
python scripts/python/PIL_draw.pypython scripts/python/batch_move.pypython scripts/python/convert_txt_format.pypython scripts/python/csv_gen.pypython scripts/python/delete_script.pypython scripts/python/image_review.pypython scripts/python/to_excel.pypython scripts/python/visualization_from_txt.pypython scripts/python/visualization_match_biaozhuTeam.pypython calculate_ssim/align_ssim_celeba_ffhq.py <dataset> <method> <dataset_src>
# 示例
python calculate_ssim/align_ssim_celeba_ffhq.py celeba fsgan CelebA/imagespython calculate_ssim/align_ssim_forensics_vgg2.py <dataset> <method> <dataset_src>
# 示例
python calculate_ssim/align_ssim_forensics_vgg2.py forensics simswap FaceForensics/original_sequencespython calculate_ssim/SSIM_quantitative.pypython calculate_headpose/demo_FSANET_ssd_celeba_ffhq.py <dataset> <method>
# 示例
python calculate_headpose/demo_FSANET_ssd_celeba_ffhq.py celeba fsganpython calculate_headpose/demo_FSANET_ssd_forensics_vgg2.py <dataset> <method>
# 示例
python calculate_headpose/demo_FSANET_ssd_forensics_vgg2.py forensics simswappython calculate_headpose/headpose_quantitative.pypython google_drive_downloader/gdrive_downloader.py <drive_file_id> <destination_file_path>
# 示例
python google_drive_downloader/gdrive_downloader.py 1XxbBesX4SjXGrXOCDuju9AqCr7BrqDpa ./datasets/datasets.zippython google_drive_downloader/download_datasets.py# 作为模块被 import 使用;也可以在其他脚本里调用:
# from download_gdrive import download_file_from_google_drivebash scripts/shell/run.shbash scripts/shell/copytxt.shbash scripts/shell/rename.shbash scripts/shell/doas-install.sh -h
bash scripts/shell/doas-install.sh -e us -y
bash scripts/shell/doas-install.sh --scm -e cn为了 Ctrl + F,这里列常搜关键词(含新目录路径):
git fetch --all && git reset --hard origin/main && git pullrsync -aWPuCUDA_VISIBLE_DEVICESscreen -d -rtmux attach -d -tpython calculate_ssim/align_ssim_celeba_ffhq.pypython calculate_headpose/demo_FSANET_ssd_forensics_vgg2.pypython scripts/python/visualization_from_txt.pybash scripts/shell/run.shpython google_drive_downloader/gdrive_downloader.pyyoutube-dlffmpeg -ss -to
当前重组已完成;后续如果你想再做“按任务域二级拆分”(例如 scripts/face_landmark/, scripts/metrics/, scripts/io/),可以继续迭代。