> For the complete documentation index, see [llms.txt](https://knowledge.tracelog.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledge.tracelog.in/linux-and-core/linux/automatic-security-update-patch-on-ubuntu.md).

# Automatic security update/patch on Ubuntu

### Problem & Goal:

Automatic update packages, every day, when have security patch

### Solution:

1. ubuntu ko tự upgrade cho mình
2. muốn tự upgrade thì cài gói `unattended-upgrades` vào, cấu hình upgrade cái gì (kernel, sec,… )
3. mỗi ngày system gọi thằng `/etc/cron.daily/apt-compat` lên làm
4. trong thằng `/etc/cron.daily/apt-compat`, nó có gọi thằng `/usr/lib/apt/apt.systemd.daily` lên execute
5. trong đây nó có chỗ set biến là 0 (tức là disable), đọc cái file `50unattended-upgrades` lên, lấy giá trị của nó, override lại cái biến khai báo = 0 ban đầu, nếu override rồi mà vẫn = 0 thì ko chạy, còn ra =1 thì update lên

Debug by using kernel/system log: `alternatives.log` + `unattended-upgrades` + `dpkg.log`

### Reference:

<https://help.ubuntu.com/community/AutomaticSecurityUpdates>
