[Linux] 查看 Ubuntu 上 OS 與套件的更新記錄
今天想要查某台 Ubuntu 機器上,有沒有就地升級過,
類似從 Ubuntu 20.04 -> 22.04 這樣子,
這要怎麼查呢?
上網查了一下,有人說在 /var/log/apt 下面,
可以從 history* 這些 log 裡看到「套件」升級的歷史記錄:
$ ll /var/log/apt/history* -rw-r--r-- 1 root root 5064 Mar 9 06:53 /var/log/apt/history.log -rw-r--r-- 1 root root 1306 Feb 28 06:10 /var/log/apt/history.log.1.gz -rw-r--r-- 1 root root 2299 Jul 29 2022 /var/log/apt/history.log.10.gz -rw-r--r-- 1 root root 1274 Jun 28 2022 /var/log/apt/history.log.11.gz -rw-r--r-- 1 root root 1483 May 27 2022 /var/log/apt/history.log.12.gz -rw-r--r-- 1 root root 4860 Jan 30 06:45 /var/log/apt/history.log.2.gz -rw-r--r-- 1 root root 1018 Dec 16 06:06 /var/log/apt/history.log.3.gz -rw-r--r-- 1 root root 1172 Nov 30 06:31 /var/log/apt/history.log.4.gz -rw-r--r-- 1 root root 1384 Oct 29 06:41 /var/log/apt/history.log.5.gz -rw-r--r-- 1 root root 1557 Sep 28 06:21 /var/log/apt/history.log.6.gz -rw-r--r-- 1 root root 245 Aug 27 2022 /var/log/apt/history.log.7.gz -rw-r--r-- 1 root root 965 Aug 19 2022 /var/log/apt/history.log.8.gz -rw-r--r-- 1 root root 1094 Aug 16 2022 /var/log/apt/history.log.9.gz
假設我們看最新的 /var/log/apt/history.log 的話:
Start-Date: 2023-03-01 06:43:33 Commandline: /usr/bin/unattended-upgrade Upgrade: libgnutls30:amd64 (3.6.13-2ubuntu1.7, 3.6.13-2ubuntu1.8) End-Date: 2023-03-01 06:43:35 Start-Date: 2023-03-01 06:43:36 Commandline: /usr/bin/unattended-upgrade Upgrade: python3-pip:amd64 (20.0.2-5ubuntu1.7, 20.0.2-5ubuntu1.8), python-pip-whl:amd64 (20.0.2-5ubuntu1.7, 20.0.2-5ubuntu1.8) End-Date: 2023-03-01 06:43:40 Start-Date: 2023-03-01 06:43:41 Commandline: /usr/bin/unattended-upgrade Upgrade: tar:amd64 (1.30+dfsg-7ubuntu0.20.04.2, 1.30+dfsg-7ubuntu0.20.04.3) End-Date: 2023-03-01 06:43:44 Start-Date: 2023-03-03 06:39:09 Commandline: /usr/bin/unattended-upgrade Install: linux-hwe-5.15-headers-5.15.0-67:amd64 (5.15.0-67.74~20.04.1, automatic), linux-headers-5.15.0-67-generic:amd64 (5.15.0-67.74~20.04.1, automatic), linux-modules-extra-5.15.0-67-generic:amd64 (5.15.0-67.74~20.04.1, automatic), linux-modules-5.15.0-67-generic:amd64 (5.15.0-67.74~20.04.1, automatic), linux-image-5.15.0-67-generic:amd64 (5.15.0-67.74~20.04.1, automatic) Upgrade: linux-headers-generic-hwe-20.04:amd64 (5.15.0.60.66~20.04.26, 5.15.0.67.74~20.04.28), linux-image-generic-hwe-20.04:amd64 (5.15.0.60.66~20.04.26, 5.15.0.67.74~20.04.28), linux-generic-hwe-20.04:amd64 (5.15.0.60.66~20.04.26, 5.15.0.67.74~20.04.28) End-Date: 2023-03-03 06:39:55 ......
裡面有各個套件被更新的時間,
但這要如何判斷有沒有就地升級呢?
想到一個方法,就是去找「套件版號裡有 OS 版號的」。
像上面的 tar:amd64 (1.30+dfsg-7ubuntu0.20.04.2),
裡面的 20.04 就是我目前的 Ubuntu 版本。
所以如果之後升級到 22.04 的話,應該會安裝到版本裡有 22.04 的套件囉~
參考資料:apt – Where can I look up my update history?
(本頁面已被瀏覽過 719 次)