Debian 11 新系统安装配置指南
以
Linux 新系统安装配置清单
为蓝本,针对 Debian 11 系统进行相应的调整。
一、 bash 配置
/root/.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| PS1='\n${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h \a\]$PS1"
;;
*)
;;
esac
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -lh'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
|
二、 公共组件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| # 备份原来的 sources.list
DATE_TIME_NOW=`date +"%Y%m%d_%H%M"`
mv /etc/apt/sources.list /etc/apt/sources.list.bak_${DATE_TIME_NOW}
# 设置 sources.list ,使用清华的镜像源
cat << \EOF > /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/debian bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
EOF
# 安装常用工具
apt install -y \
curl \
gnupg2 \
vim \
tmux \
nfs-common \
zip \
unzip \
unar \
p7zip-full \
fonts-noto-cjk \
fonts-wqy-microhei \
fonts-wqy-zenhei
# vim 设置,写到 vimrc.local 中,避免更新时冲突。
cat << \EOF > /etc/vim/vimrc.local
" 显示行号
set nu
" 设置 yaml 文件缩进
autocmd FileType yaml,yml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=<:>
EOF
|
三、 python 环境
1. pip 私服
/etc/pip.conf
1
2
3
4
5
6
7
| [global]
# 豆瓣源
# index-url = https://pypi.douban.com/simple
# 清华源
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里云源
# index-url = https://mirrors.aliyun.com/pypi/simple
|
使用方法参考
Python 设置 PYPI 私服说明
2. 虚拟环境设置
安装虚拟环境工具
1
| apt install python3-virtualenvwrapper
|
配置
/etc/bash.bashrc
1
2
3
4
5
6
7
8
9
| # 加载 virtualenvwrapper 脚本
if [ -f /usr/share/virtualenvwrapper/virtualenvwrapper.sh ]; then
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME='~/.virtualenvs'
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
fi
# 让 pip 使用系统证书
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
|
使用方法参考
virtualenvwrapper 安装配置说明
四、 docker 环境
运行以下命令进行安装
1
| apt install docker.io docker-compose
|