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.

  1. 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.
  2. ** 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.
  3. ** 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.service

In the [Service] section add:

TimeoutStartSec=2sec

Reload the configuration after saving:

sudo systemctl daemon-reload

Disable 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.service

Optimize network configuration

Check /etc/netplan/50-cloud-init.yaml or similar file to make sure DHCP is configured correctly. For example:

ethernets:
  eth0:
    dhcp4: true

For fixed IP environments, avoid DHCP delays‌ by switching to a static IP.

timedatectl

  1. Set time zone
sudo timedatectl set-timezone Asia/Shanghai

timedatectl status #验证
  1. 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 tracking

usermod

usermod -aG lpadmin username # 将用户名添加到 lpadmin
cat /etc/group