Debian 11 最小化安装及基本配置

1. 安装

2. 网络

  • DHCP
1
2
3
4
$ vi /etc/network/interfaces
auto ens33
iface ens33 inet dhcp
$ systemctl restart networking
  • STATIC
1
2
3
4
5
6
7
8
9
$ vi /etc/network/interfaces
auto ens33
iface ens33 inet static
address 10.4.7.100
netmask 255.255.255.0
gateway 10.4.7.2
$ vi /etc/resolv.conf
nameserver 8.8.8.8
$ systemctl restart networking

3. 用户免密登录

1
2
3
4
5
6
7
8
$ su -
$ apt install sudo
$ usermod -aG sudo liubin

# $ visudo
$ chmod +w /etc/sudoers
$ vi /etc/sudoers
%liubin ALL=(ALL) NOPASSWD: ALL

4. root 可登录

1
2
3
4
$ sudo vim /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
$ systemctl restart sshd

5. 镜像源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ sudo tee /etc/apt/sources.list << EOF
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
#deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
#deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
#deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
#deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
EOF
$ sudo apt update
$ sudo apt upgrade -y

# # PVE
# $ cat sources.list.d/pve-enterprise.list
# #deb https://enterprise.proxmox.com/debian/pve bullseye pve-enterprise

6. 常用软件

1
$ sudo apt install vim bash-completion wget curl net-tools git rsync -y

7. 时间同步

1
2
3
4
5
$ sudo timedatectl set-timezone Asia/Shanghai
$ timedatectl

$ sudo apt install ntpdate -y
$ sudo ntpdate cn.pool.ntp.org

8. 个性化配置

1
2
3
4
5
6
7
8
9
10
11
12
13
$ sudo tee /etc/profile.d/alias.sh << EOF
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls --color=auto'
alias ll='ls --color=auto -lA'
alias l='ls --color=auto -l'
EOF
$ sudo tee /etc/profile.d/my.sh << EOF
export PS1="\[\e[35;1m\][\u@\h \W]$>\[\e[0m\]"
EOF

$ source /etc/profile

9. 密钥登录

1
2
3
4
$ mkdir ~/.ssh/
$ tee ~/.ssh/authorized_keys << EOF
(公钥内容)
EOF