工具
- edit
命令行编辑器
https://github.com/microsoft/edit - chscr
换源工具
https://github.com/RubyMetric/chsrc - cherry-studio
llm聊天前端 免安装
https://github.com/CherryHQ/cherry-studio
安装命令
apt
test -e /etc/apt/sources.list || echo "deb http://mirrors.aliyun.com/debian bookworm main" > /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security bookworm-security main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian bookworm-updates main" >> /etc/apt/sources.list
# 清华源
# test -e /etc/apt/sources.list || echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian bookworm main" > /etc/apt/sources.list && \
# echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main" >> /etc/apt/sources.list && \
# echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main" >> /etc/apt/sources.list
docker 安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
apt update
apt upgrade -y
apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates
curl -sSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://download.docker.com/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list
# 清华源
# curl -sS https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list
apt update
apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
cat > /etc/docker/daemon.json << EOF
{
"log-driver": "json-file",
"log-opts": {
"max-size": "20m",
"max-file": "3"
},
"ipv6": true,
"fixed-cidr-v6": "fd00:dead:beef:c0::/80",
"experimental":true,
"ip6tables":true,
"registry-mirrors": [
"https://func.ink",
"https://dytt.online",
"https://lispy.org",
"https://docker.m.daocloud.io",
"https://a.ussh.net",
"https://docker.zhai.cm",
"https://6azbt4va.mirror.aliyuncs.com"
]
}
EOF
systemctl restart docker
单脚本换源
bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry
conda 安装
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
# 一路默认
rust 安装
# 过时
mkdir -p ~/.cargo && echo 'export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"' >>~/.bashrc && echo '[source.crates-io]
replace-with = "rsproxy-sparse"
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true' >~/.cargo/config && source ~/.bashrc && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && source ~/.cargo/env && rustup target add x86_64-unknown-linux-musl && cargo version && rustc --version
gcc
apt update
apt install build-essential
golang
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz
wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
echo '# GO install
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
# END GO install
' >> ~/.profile
source ~/.profile
使用
docker
根据 pid 来定位 docker 容器
# 1. 获取 pid, 使用 ps -aux, top等
# 2. 查找容器 ID
cat /proc/[PID]/cgroup
# 输出类似于 1:name=systemd:/docker/[CONTAINER_ID]
# 3. 截取 前十二位[短容器ID], 使用docker ps即可
docker ps | grep [短容器ID]
docker compose 修改端口映射
如果没有启动则直接修改 docker-compose.yaml
文件
如果已经在运行, 则
docker compose stop
docker compose up -d
进行手动重启, docker compose restart
无法修改
pip
镜像源
- 清华源: https://pypi.tuna.tsinghua.edu.cn/simple
- 阿里源: https://mirrors.aliyun.com/pypi/simple/
- 中科大源: https://pypi.mirrors.ustc.edu.cn/simple
uv
python 镜像源
UV_PYTHON_INSTALL_MIRROR=https://github.com/indygreg/python-build-standalone/releases/download uv python install 3.13.1 # python镜像 或者 export
pip 镜像源 export UV_DEFAULT_INDEX="https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
或
# pyproject.toml
[[tool.uv.index]]
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
default = true
# uv.toml
[[index]]
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
default = true
初始化
cd /path/to/project
uv init
uv venv 名字 --python 3.12
虚拟环境
source .venv/bin/activate # 激活虚拟环境
deactivate # 退出虚拟环境
github
升级git:
# git update # 2.17.1之前
git update-git-for-windows
# linux 直接使用包管理工具更新
git config --global user.name 名字
git config --global user.email 邮箱
安装 glt lfs
apt install git-lfs # 安装lfs
# yum install git-lfs
git lfs install
huggingface
export HF_ENDPOINT=https://hf-mirror.com
$env:HF_ENDPOINT = "https://hf-mirror.com"
conda
给环境新增名字(vscode 创建 conda 环境无名字)
conda config --describe envs_dirs
conda config --append envs_dirs /path/to/the/parent_dir
vim
解决粘贴格式混乱
进入命令模式输入 :set paste
粘贴完成后输入 :set nopaste
恢复默认缩进
linux
添加环境变量
-
临时
export PATH=/to/your/path/:$PATH
-
永久
echo " export PATH=/to/your/path/:$PATH " >> ~/.bashrc # debian 系 # echo " # export PATH=/to/your/path/:$PATH # " >> /etc/profile
单脚本换源
bash <(curl -sSL https://linuxmirrors.cn/main.sh)
重装 linux
需要先切换软件源到国内
https://github.com/leitbogioro/Tools
wget --no-check-certificate -qO InstallNET.sh 'https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/InstallNET.sh' && chmod a+x InstallNET.sh
bash InstallNET.sh -debian
查看端口占用
lsof -i:[端口号]
排序cpu与内存占用
top # 打开top后,按大写的P来根据cpu排序,按大写的M来根据内存排序
screen
screen -S yourname # 新建一个叫yourname的session
screen -ls # 列出当前所有的session
screen -r yourname # 回到yourname这个session
screen -d yourname # 远程detach某个session
screen -d -r yourname # 结束当前session并回到yourname这个session 注: 一个session只能由一个用户进入, 第二个用户需要使用 -d -r 来中断前面一个用户的session
解压
tar -xvf xxxx.tar
tar -xzvf xxxx.tar.gz
unzip xxxx.zip # 创建文件夹后, 解压到对应文件夹
git 命令
-
覆盖本地拉代码
git fetch git reset --hard HEAD git pull
转载无需注明出处