“Debian 环境如何配置”范围比较广,下面我按最常见场景给你一个从零开始的可操作清单,你可以按需取用。如果你指的是某种特定环境(如开发环境、服务器、容器、桌面、Python/Java/Node 等),可以再告诉我。
sudo apt update
sudo apt upgrade -y
sudo hostnamectl set-hostname debian-server
adduser yourname
usermod -aG sudo yourname
sudo apt install network-manager
sudo systemctl enable --now NetworkManager
编辑:
sudo nano /etc/network/interfaces
示例:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
重启网络:
sudo systemctl restart networking
sudo apt install -y curl wget git vim unzip htop tmux
sudo apt install -y build-essential cmake
sudo apt install -y python3 python3-pip python3-venv
创建虚拟环境:
python3 -m venv venv
source venv/bin/activate
sudo apt install -y openssh-server
sudo systemctl enable --now ssh
禁止 root 登录(安全):
sudo nano /etc/ssh/sshd_config
PermitRootLogin no
sudo systemctl restart ssh
sudo apt install -y ufw
sudo ufw allow 22
sudo ufw enable
sudo timedatectl set-timezone Asia/Shanghai
sudo apt install -y locales
sudo dpkg-reconfigure locales
sudo apt install -y docker.io docker-compose
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
用户级:
nano ~/.bashrc
export PATH=$PATH:/your/path
source ~/.bashrc
系统级:
sudo nano /etc/environment
| 场景 | 建议 |
|---|---|
| 服务器 | SSH + UFW + 非 root 用户 |
| 开发机 | Python/Node + Docker |
| 桌面 | GNOME / KDE + NetworkManager |
| 容器基础 | debian:slim |
如果你能告诉我:
我可以直接给你一套精确配置命令。