1. 网络配置
Key | Value |
---|---|
IP Address |
|
Subnet |
|
Address |
|
Gateway |
|
NameServer |
|
Account |
|
Name |
Noble |
Server Name |
noble-docker |
UserName |
noble |
Password |
elf |
Confirm Password |
elf |
apt install net-tools -y
vim /etc/netplan/00-installer-config.yaml
netplan apply
network:
ethernets:
eth0:
addresses:
- 192.168.1.120/24
nameservers:
addresses:
- 114.114.114.114
- 8.8.8.8
search: []
routes:
- to: default
via: 192.168.1.1
version: 2
2. 账户设置
-
不要安装非LTS版本,如Ubuntu Server 23.04,
否则可能登录后SSH服务都找不到 -
安装成功后重启,使用noble - elf登录
-
root密码修改
sudo -s
sudo passwd root
elf - elf
sudo reboot now
3. SSH设置
vim /etc/ssh/sshd_config
PermitRootLogin yes
systemctl restart sshd
systemctl enable ssh
systemctl daemon-reload
systemctl restart ssh.socket
systemctl status ssh
# ufw allow 22
ufw allow ssh
ufw enable
# ssh noble@192.168.0.12345 -p 22
ssh userName@serverIpOrHostname
4. Mirror Source
Ubuntu Version | Command |
---|---|
Ubuntu 24.04 Noble |
vim /etc/apt/sources.list.d/ubuntu.sources |
Ubuntu 22.04 Jammy |
vim /etc/apt/sources.list |
5. Ubuntu Jammy
-
vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu jammy main restricted
deb http://cn.archive.ubuntu.com/ubuntu jammy-updates main restricted
deb http://cn.archive.ubuntu.com/ubuntu jammy universe
deb http://cn.archive.ubuntu.com/ubuntu jammy-updates universe
deb http://cn.archive.ubuntu.com/ubuntu jammy-updates multiverse
deb http://cn.archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu jammy-security main restricted
deb http://cn.archive.ubuntu.com/ubuntu jammy-security universe
deb http://cn.archive.ubuntu.com/ubuntu jammy-security multiverse
6. Ubuntu Noble
-
vim /etc/apt/sources.list.d/ubuntu.sources
Types: deb deb-src
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb deb-src
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb deb-src
URIs: http://mirrors.163.com/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb deb-src
URIs: https://mirrors.ustc.edu.cn/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: http://cn.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
6.3. Suite
-
指与Ubuntu发布周期的不同版本或Stage对齐的特定软件包集
Entry | Memo |
---|---|
noble |
初始版本包 |
noble-updates |
更新包 |
noble-backports |
向后移植backport |
noble-security |
安全漏洞 |
7. 时间同步
-
一般涉及容器会涉及到时间同步,如ntp,timezone等,解决方案有很多,
如启动容器时指定或构建镜像时设置或从设定好的主机复制,
此处采用主机和构建镜像时独立设置,如Aisa/Shanghai
# Ubuntu 24.04
timedatectl set-timezone Asia/Shanghai && \
timedatectl set-local-rtc 1 && \
systemctl restart rsyslog && timedatectl status
# Ubuntu 22.04
timedatectl set-timezone Asia/Shanghai && \
timedatectl set-local-rtc 1 && \
hwclock --localtime --systohc && \
systemctl restart rsyslog && timedatectl status
# timedatectl list-timezones | grep keyword
# timedatectl list-timezones | grep Asia/Shanghai
# timedatectl set-timezone Region/Location
# timedatectl set-timezone Asia/Shanghai
# timedatectl set-time YYYY-MM-DD
# timedatectl set-time 2022-09-01
# timedatectl set-time HH:MM:SS
# timedatectl set-time 14:38:30
# apt install ntpdate
# ntpdate time.windows.com
# 设置硬件时间为本地时间
# timedatectl set-local-rtc 1
# 设置硬件时间为UTC时间
# timedatectl set-local-rtc 0
# 本地时间更新到硬件
# hwclock --localtime --systohc
# 启动ntp时间同步
# timedatectl set-ntp true
# 禁用ntp时间同步
# timedatectl set-ntp false
date +"%Z %z" && cat /etc/timezone && \
ls -l /etc/localtime && timedatectl status
tzselect => Asia => China => BeiJing => Yes
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
=> date -R
8. 语言环境
-
查询当前设定及已安装Locale:
locale && locale -a
-
Linux语系通过变量来设置,其它变量会通过LANG和LC_ALL传递变化,
LANG是定义系统主语系的变量,LC_ALL是定义整体语系的变量,
另需通过/etc/sysconfig/i18n定义系统默认语系 -
修改/etc/default/locale
-
特定于用户的$HOME/.pam_environment
-
gnome-language-selector
$ vim /etc/default/locale
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh
LC_ALL=zh_CN.UTF-8
$ locale-gen zh_CN.UTF-8
$ reboot now
$ echo $LANG && locale
# 容器设置语言环境:apt install -y language-pack-zh-hans
RUN locale-gen && update-locale LANG=zh_CN.UTF-8 && \
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 && \
localectl set-locale LANG=zh_CN.UTF-8
ENV LC_ALL zh_CN.UTF-8
-
Microsoft Wsl方案:
-
vim /etc/default/locale
-
LANG=C.UTF-8
⇒LANG=zh_CN.UTF-8
-
apt install -y language-pack-zh-hans
-
退出终端并重新登录
-