pip / uv
# 清华
-i https://pypi.tuna.tsinghua.edu.cn/simple
# 南大
-i https://mirrors.nju.edu.cn/pypi/web/simple
--index-url https://mirrors.nju.edu.cn/pytorch/whl/cu129
# 交大
-f https://mirror.sjtu.edu.cn/pytorch-wheels/cu124
# 科大
-i https://pypi.mirrors.ustc.edu.cn/simple/
# 阿里
-i https://mirrors.aliyun.com/pypi/simple/
-f https://mirrors.aliyun.com/pytorch-wheels/cu124
# 下载uv 加速
curl -LsSf https://uv.agentsmirror.com/install-cn.sh | sh
export UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
export HF_ENDPOINT=https://hf-mirror.com
linux
# 查找 / 下 前30大的文件夹
sudo du -xh / | sort -rh | head -30
数东西
| 命令 | 功能 |
|---|---|
| ls | wc -w | 查看有多少个文件及文件夹 |
| ls | wc -c | 查看目录下多少个字节数 |
| ls -l |grep "^-"|wc -l | 统计某文件夹下文件的个数 |
| ls -l |grep "^d"|wc -l | 统计某文件夹下目录的个数 |
| ls -lR|grep "^-"|wc -l | 统计文件夹下文件的个数,包括子文件夹里的 |
network
# 设置 HTTP 和 HTTPS 代理
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
# 如果代理支持 SOCKS5,也可以使用:
# export ALL_PROXY="socks5://127.0.0.1:7890"
win
# cmd
set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890
set http_proxy=
set https_proxy=
# powershell
$env:http_proxy="http://127.0.0.1:7890"
$env:https_proxy="http://127.0.0.1:7890"
Remove-Item Env:\http_proxy
Remove-Item Env:\https_proxy
# apt 源
ip
ip route get xx.xx.xx.xx
ifconfig
nslookup
# sudo apt install dnsutils -y
netplan
# sudo apt install netplan.io
win (powershell)
PowerShell (PS) 的命令称为 Cmdlet,遵循 动词-名词 (Verb-Noun) 的命名规范(如 Get-Process)。
文件/目录操作
| 功能 | PowerShell 命令 | 别名 | Linux 对应 |
|---|---|---|---|
| 列出文件 | Get-ChildItem |
ls, dir, gci |
ls |
| 切换目录 | Set-Location |
cd, sl |
cd |
| 显示路径 | Get-Location |
pwd, gl |
pwd |
| 新建文件夹 | New-Item -ItemType Directory |
mkdir |
mkdir |
| 新建文件 | New-Item -ItemType File |
ni |
touch |
| 复制 | Copy-Item |
cp, copy |
cp |
| 移动/重命名 | Move-Item |
mv, move |
mv |
| 删除 | Remove-Item |
rm, del, ri |
rm |
| 查看内容 | Get-Content |
cat, gc |
cat |
| 查找文件 | Get-ChildItem -Recurse -Filter *.txt |
- | find . -name "*.txt" |
技巧:
ls在 PS 中返回的是对象而非纯文本,你可以直接.Name或.Length获取属性。
进程/服务管理
对应 Linux
ps,kill,systemctl
| 功能 | PowerShell 命令 | 别名 | Linux 对应 |
|---|---|---|---|
| 查看进程 | Get-Process |
gps, ps |
ps aux |
| 停止进程 | Stop-Process -Name "chrome" |
spps |
kill |
| 查看服务 | Get-Service |
gsv |
systemctl list-units |
| 启动服务 | Start-Service -Name "wuauserv" |
sasv |
systemctl start |
| 停止服务 | Stop-Service -Name "wuauserv" |
spsv |
systemctl stop |
| 重启服务 | Restart-Service -Name "spooler" |
rsv |
systemctl restart |
网络与系统
对应 Linux
ifconfig,ping,top
| 功能 | PowerShell 命令 | 备注 |
|---|---|---|
| IP 配置 | Get-NetIPConfiguration |
比 ipconfig 更详细,对象化输出 |
| 测试连通性 | Test-Connection google.com |
类似 ping,但默认只发 4 个包 |
| 端口监听 | Get-NetTCPConnection -LocalPort 80 |
查看谁占用了 80 端口 |
| 系统信息 | Get-ComputerInfo |
获取 OS 版本、内存等详细信息 |
| 环境变量 | $env:PATH |
查看 PATH;$env:JAVA_HOME = "C:\Java" 设置临时变量 |
管道与过滤
对应 Linux
grep,awk,head
PowerShell 的强大之处在于对象管道,而不是文本流。
-
过滤 (Where-Object) -> 对应
grep/filter# 找出所有占用内存大于 100MB 的进程 Get-Process | Where-Object { $_.WorkingSet64 -gt 100MB } # 简写形式 (? 是 Where-Object 的别名) Get-Process | ? WorkingSet64 -gt 100MB -
选择属性 (Select-Object) -> 对应
awk/cut# 只显示进程名和 ID Get-Process | Select-Object Name, Id -
排序 (Sort-Object) -> 对应
sort# 按 CPU 使用率降序排列 Get-Process | Sort-Object CPU -Descending -
前 N 行 (Select-Object -First) -> 对应
headGet-Process | Select-Object -First 5 -
全文搜索 (Select-String) -> 对应
grep# 在日志文件中搜索 "Error" Select-String -Path "app.log" -Pattern "Error"
帮助与探索
- 获取帮助:
Get-Help Get-Process -Examples # 查看示例 Get-Help Get-Process -Full # 查看完整文档 - 查找命令:
Get-Command *service* # 查找所有包含 service 的命令 - 查看对象属性:
Get-Process | Get-Member # 查看当前对象有哪些属性和方法可以调用