需要准备
- 显示器
- HDMI线连接显示器
- 键盘
- 至少8GB的U盘
- 网线
装系统
- Ubuntu或Debian官网下载镜像
- 准备一个至少8GB的U盘,安装Etcher,按照流程将Ubuntu镜像烧写到U盘中
- 将U盘插入PC,启动,然后不断点击
F7键,不同的主板按键不同,然后进入Bios - 我需要将整个磁盘都分配给Ubuntu,后续也不折腾的话可以不选择LVM Group,这样只会产生两个分区,
/和/boot/efi - 后面的无脑填就可以了,等到进入系统
Ubuntu 24.04
-
一般来说安装完系统就dhcp连接wifi了,但是我习惯了静态IP地址,而且打算将一个网口连接在路由器上,因此需要修改默认的IP地址
-
首先
ip addr查看当前的地址信息 -
我们打算把
enp0s1的IP地址修改为192.168.2.66,然后默认网关为主路由器192.168.2.1。我们需要编辑文件01-netcfg.yaml,没有的话就新建network: version: 2 renderer: networkd ethernets: enp1s0: dhcp4: no addresses: - 192.168.2.66/24 routes: - to: default via: 192.168.2.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 -
如果提示Permission too open,则修改权限
sudo chmod 600 /etc/netplan/01-netcfg.yaml -
应用Netplan配置
sudo netplan apply -
重启网络服务(可选)
sudo systemctl restart systemd-networkd -
插入网线,验证配置
ip addr
Debian 12
-
最近试了试Debian 13,虽然说想要慢慢淡化interfaces (ifupdown)的网络管理方式,但是我发现Debian 13(服务器版)的默认版还是这个
-
首先查看网卡名称
ip addr我的是
ens18 -
编辑文件
/etc/network/interfaces# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto ens18 iface ens18 inet static address 192.168.2.111/24 # 本机的IP地址 network 192.168.2.0 broadcast 192.168.2.255 gateway 192.168.2.1 dns-nameservers 8.8.8.8 -
如果你的Linux是Wi-Fi连接,一样的
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto wlp2s0 allow-hotplug wlp2s0 iface wlp2s0 inet static address 192.168.2.111 # 本机的IP地址 netmask 255.255.255.0 # Mask gateway 192.168.2.1 # 网关 dns-nameservers 192.168.2.1 # DNS wpa-ssid YourWiFiSSID wpa-psk YourWiFiPassword -
重启网络服务
sudo systemctl restart networking.service -
由于刚开始默认是DHCP管理网络,系统会在
/etc/resolv.conf生成路由器发来的默认dns server,但是改为static之后这个文件在重启之后就会被清空,所以我们得给这个文件加个锁su - chattr +i /etc/resolv.conf或者安装
resolvconf软件包,它会收集interfaces里的 DNS 信息并同步到resolv.conf文件,两种都可以,直接加锁更简单粗暴一点,这样重启之后也不会断网
其他配置
剩下的就是一些基本的其他配置了
-
安装sudo
su root apt install sudo # 将用户添加到sudo组 sudo usermod -aG sudo username # 免密码 sudo visudo # 修改文件内容 %sudo ALL=(ALL:ALL) NOPASSWD: ALL -
安装vim
sudo apt install vim -
更换时区
sudo timedatectl set-timezone America/Toronto -
安装Openssh
sudo apt update sudo apt install openssh-server -
安装Docker,详见:将OpenWrt制作为Docker镜像 | Kunyang’s Blog
-
切换
zsh-
下载
sudo apt update sudo apt install zsh git curl -y sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # 自动建议插件 git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions # 语法高亮插件 git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting -
配置
cat > ~/.zshrc << 'EOF' export ZSH="$HOME/.oh-my-zsh" # ZSH_THEME="robbyrussell" ZSH_THEME="philips" plugins=( git docker docker-compose zsh-autosuggestions zsh-syntax-highlighting ) source $ZSH/oh-my-zsh.sh # 常用 alias alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' alias grep='grep --color=auto' EOF -
刷新
source ~/.zshrc
-