Ubuntu Packages有一個自動更新機制,可以幫助用戶自動更新系統中的軟件包。用戶可以通過以下步驟來啟用自動更新機制:
打開終端,并輸入以下命令來安裝unattended-upgrades軟件包:
sudo apt-get install unattended-upgrades
安裝完成后,編輯/etc/apt/apt.conf.d/50unattended-upgrades文件,確保以下內容已經設置:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
};
編輯/etc/apt/apt.conf.d/10periodic文件,設置自動更新的頻率和時間:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
最后,啟用unattended-upgrades服務:
sudo systemctl enable unattended-upgrades
sudo systemctl start unattended-upgrades
通過以上步驟,系統將會自動更新軟件包,保持系統安全和穩定。