Linux配置
Ubuntu配置¶
软件镜像源¶
备份并修改/etc/apt/sources.list
Text Only
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
终端(fish)¶
方法一:在~/.bashrc
中添加(不需要迁移原有的脚本):
fish中运行conda:在bash中运行:
方法二:迁移脚本到/etc/fish/config.fish
(所有用户)或~/.config/fish/config.fish
(当前用户)
Git¶
生成rsa密钥:默认目录为~/.ssh
测试ssh连接:
C/C++¶
1.直接安装构建基础包
2.安装(GNU C/C++)
3.安装(clang)
CUDA¶
Python(miniconda)¶
下载并安装miniconda后,在~/.condarc
中修改:
Text Only
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
清除索引缓存:
conda命令(tldr):
Bash
conda create --name "虚拟环境名" python=3.11
conda info --envs
conda activate "虚拟环境名" /deactivate
conda remove --name "虚拟环境名" --all
conda install "包名"
conda list
conda clean --all
Rustup/crates.io¶
- 设置Rustup镜像,在
~/.bashrc
中添加:
Bash
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
并重启终端。
- 安装Rust
- 设置crates.io镜像, 修改配置文件
~/.cargo/config
Text Only
[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
实用工具¶
-
文本编辑器(gedit,vim)
-
文件管理器(nautilus)
-
非常好用:命令速查Too Long Didn't Read(tldr)
第一次运行时更新数据库(需要连接到github)
-
系统监控(htop,btop)
-
视频音频转换(ffmpeg)
-
图像转换(imagemagick)
临时访问github(修改hosts)¶
在/etc/hosts
中添加:注意ip地址会变,通过解析域名的网站获取。
Text Only
199.232.69.194 github.global.ssl.fastly.net
140.82.113.3 github.com
185.199.108.154 github.githubassets.com
刷新DNS:
WSL2中通过Clash for Windows设置代理¶
-
Clash for Windows客户端设置
-
修改端口号(默认为7890),以16514为例
-
打开Allow LAN
-
修改
~/.bashrc
Bash
host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
export http_proxy="http://$host_ip:[端口]"
export https_proxy="http://$host_ip:[端口]"
- 使用root用户保留之前设置的环境变量
运行sudo visudo
-
Ubuntu20.04
加入该行
-
Ubuntu22.04
取消该行注释
-
测试
-
输入
source ~/.bashrc
,通过echo $http_proxy
检查端口号 - 输入
wget www.google.com
检查连接。