This note records the notes that need to be set when using Ubuntu daily.
systemd-networkd-wait-online.service
systemd-networkd-wait-online.service is a service unit of Systemd, mainly used to wait for the network connection to be ready when the system starts.
- Function: This service will wait for systemd-networkd to complete the network configuration and confirm that at least one network interface is online before it is marked as ready, allowing other network-dependent services to start. By default, it monitors all network interfaces managed by systemd-networkd until the connection is successful or times out.
- ** FAQ **: If DHCP takes a long time to obtain an IP, the system startup may be stuck in this service; when there is no network connection, it may also wait until it times out.
- ** optimization method **: You can adjust the timeout, disable services, or check the network configuration.
Adjust timeout
Set TimeoutStartSec to 2sec:
sudo vim /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.serviceIn the [Service] section add:
TimeoutStartSec=2secReload the configuration after saving:
sudo systemctl daemon-reloadDisable service
If you don’t strictly need to wait for the network to be ready, you can disable and block the service:
sudo systemctl disable systemd-networkd-wait-online.service
sudo systemctl mask systemd-networkd-wait-online.serviceOptimize network configuration
Check /etc/netplan/50-cloud-init.yaml or similar file to make sure DHCP is configured correctly. For example:
ethernets:
eth0:
dhcp4: trueFor fixed IP environments, avoid DHCP delays by switching to a static IP.
timedatectl
- Set time zone
sudo timedatectl set-timezone Asia/Shanghai
timedatectl status #验证- Turn on time synchronization and set up NTP server
apt-get install chrony -y
cd /etc/chrony
vim chrony.conf
server time.google.com iburst
server time2.google.com iburst
server time3.google.com iburst
systemctl enable chronyd
systemctl restart chronyd
# 检查服务状态、同步源及同步状态
sudo systemctl status chronyd
chronyc sources -v
chronyc trackingusermod
usermod -aG lpadmin username # 将用户名添加到 lpadmin
cat /etc/group