环境

Ubuntu24服务器版最小化安装

设置root密码

sudo passwd root
#设置完后登录root用户
su root

网络配置

由于最小化安装的Ubuntu没有自带的文本编辑器,故使用netplan配置网络

ip link show  #查看当前网卡名
ip set
netplan set ethernets.enp6s18.dhcp4=true #开启DHCP自动获取IP
netplan apply #应用网卡配置
apt install -y vim #安装vim编辑器
vim /etc/netplan/[你的网卡配置文件].yaml

按照如下模板配置

network:
ethernets:
ens18:
dhcp4: false
addresses:
- 192.168.50.76/24 #ip
routes:
- to: default
via: 192.168.22.22 #网关
nameservers:
addresses: [8.8.8.8] #DNS


最后netplan apply一下

ssh登录配置

apt-get install -y openssh-server #安装ssh服务端
vim /etc/ssh/sshd_config #打开配置文件

#找到 PermitRootLogin 这行,修改如下
PermitRootLogin yes
#保存退出

systemctl restart ssh #重启ssh服务

换源

apt换源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
vim /etc/apt/sources.list #将里面内容替换为下面的镜像

清华大学镜像站

# 默认注释了源码镜像以提高 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

更新本地缓存

sudo apt-get update

pip换源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

END~~