Linux OSのアップデート手順を紹介します。
やすひら
OSのアップデート手順を紹介します
この記事でわかること
- Linux OSのアップデート手順
目次
Linux OSのアップデート手順
Linux OSのアップデート手順を紹介します。
パッケージリストを更新する
アップデート可能なパケージのリストを更新します。
コマンド実行例
$ sudo apt update -y
[sudo] password for user:
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
8 packages can be upgraded. Run 'apt list --upgradable' to see them.
パッケージを更新する
更新したパッケージリストのパッケージを更新します。
コマンド実行例
$ sudo apt upgrade -y
[sudo] password for user:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
libfile-copy-recursive-perl openbsd-inetd tcpd update-inetd
Use 'sudo apt autoremove' to remove them.
The following security updates require Ubuntu Pro with 'esm-infra' enabled:
libpam0g libc-ares2 screen libwebp6 libkrb5-3 libgssapi-krb5-2 python2.7-dev
libpython3.6-minimal libnghttp2-14 libisccfg160 intel-microcode
linux-headers-generic libsndfile1-dev linux-libc-dev vim-common libcurl4
libldap-2.4-2 libpam-modules openssl libgdk-pixbuf2.0-0 libc6-dev
libpython3.6-dev libsystemd0 linux-image-generic python2.7-minimal
libpam-cap libpython3.6-stdlib libelf1 python3-urllib3 binutils libirs160
bind9-host librbd1 open-iscsi dnsutils libpython2.7 libncurses5 python2.7
dnsmasq-base libc6 libpython3.6 python3.6 open-vm-tools openssh-sftp-server
gawk libk5crypto3 libisc169 python3-idna libpython2.7-dev udev locales
passwd procps libklibc libpam-runtime amd64-microcode libncursesw5
libprocps6 libx11-6 python3-requests linux-signed-generic libudev1 libvpx5
libapparmor1 lxd libflac-dev krb5-locales python3.6-minimal
python-cryptography binutils-x86-64-linux-gnu libtiff5 libisc-export169
python3-cryptography busybox-static libc-bin libtinfo5 libkrb5support0
libcap2 qemu-utils tar systemd-sysv libcap2-bin libldap-common liblwres160
vim-runtime vim libpam-systemd libsndfile1 ncurses-term systemd
libgdk-pixbuf2.0-bin login libssh-gcrypt-4 xxd libwebpmux3 ncurses-bin
libpam-modules-bin openssh-server libx11-data libgdk-pixbuf2.0-common
openssh-client libdns-export1100 libnss-systemd binutils-common
libglib2.0-data ncurses-base libc-dev-bin libxml2 libflac8 libbinutils
libpython2.7-minimal multiarch-support libgnutls30 qemu-guest-agent vim-tiny
apparmor dns-root-data libisccc160 python-idna libssl1.1 libbind9-160
python3-jinja2 accountsservice python3.6-dev libdns1100 libpython2.7-stdlib
curl qemu-block-extra klibc-utils linux-generic lxd-client libglib2.0-0
librados2 uidmap libcurl3-gnutls less libx11-xcb1 libaccountsservice0
libssl1.0.0 tzdata busybox-initramfs
Learn more about Ubuntu Pro for 18.04 at https://ubuntu.com/18-04
The following NEW packages will be installed:
efibootmgr libefiboot1 libefivar1 ubuntu-pro-client ubuntu-pro-client-l10n
The following packages will be upgraded:
grub-common grub-pc grub-pc-bin grub2-common python3-update-manager
ubuntu-advantage-tools update-manager-core update-notifier-common
8 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 3895 kB of archives.
After this operation, 662 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 update-manager-core all 1:18.04.12 [8512 B]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-update-manager all 1:18.04.12 [35.3 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ubuntu-advantage-tools all 32.3~18.04 [11.0 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ubuntu-pro-client amd64 32.3~18.04 [207 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 update-notifier-common all 3.192.1.21 [172 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ubuntu-pro-client-l10n amd64 32.3~18.04 [18.5 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libefivar1 amd64 34-1 [46.2 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libefiboot1 amd64 34-1 [23.5 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 efibootmgr amd64 15-1 [28.2 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 grub2-common amd64 2.02-2ubuntu8.26 [533 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 grub-pc amd64 2.02-2ubuntu8.26 [138 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 grub-pc-bin amd64 2.02-2ubuntu8.26 [901 kB]
Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 grub-common amd64 2.02-2ubuntu8.26 [1773 kB]
Fetched 3895 kB in 5s (733 kB/s)
Preconfiguring packages ...
(Reading database ... 116853 files and directories currently installed.)
Preparing to unpack .../00-update-manager-core_1%3a18.04.12_all.deb ...
Unpacking update-manager-core (1:18.04.12) over (1:18.04.11.13) ...
Preparing to unpack .../01-python3-update-manager_1%3a18.04.12_all.deb ...
Unpacking python3-update-manager (1:18.04.12) over (1:18.04.11.13) ...
Preparing to unpack .../02-ubuntu-advantage-tools_32.3~18.04_all.deb ...
Unpacking ubuntu-advantage-tools (32.3~18.04) over (29.4~18.04) ...
dpkg: warning: unable to delete old directory '/var/lib/ubuntu-advantage': Direc
tory not empty
dpkg: warning: unable to delete old directory '/etc/ubuntu-advantage': Directory
not empty
Selecting previously unselected package ubuntu-pro-client.
Preparing to unpack .../03-ubuntu-pro-client_32.3~18.04_amd64.deb ...
Unpacking ubuntu-pro-client (32.3~18.04) ...
Preparing to unpack .../04-update-notifier-common_3.192.1.21_all.deb ...
Unpacking update-notifier-common (3.192.1.21) over (3.192.1.19) ...
Selecting previously unselected package ubuntu-pro-client-l10n.
Preparing to unpack .../05-ubuntu-pro-client-l10n_32.3~18.04_amd64.deb ...
Unpacking ubuntu-pro-client-l10n (32.3~18.04) ...
Selecting previously unselected package libefivar1:amd64.
Preparing to unpack .../06-libefivar1_34-1_amd64.deb ...
Unpacking libefivar1:amd64 (34-1) ...
Selecting previously unselected package libefiboot1:amd64.
Preparing to unpack .../07-libefiboot1_34-1_amd64.deb ...
Unpacking libefiboot1:amd64 (34-1) ...
Selecting previously unselected package efibootmgr.
Preparing to unpack .../08-efibootmgr_15-1_amd64.deb ...
Unpacking efibootmgr (15-1) ...
Preparing to unpack .../09-grub2-common_2.02-2ubuntu8.26_amd64.deb ...
Unpacking grub2-common (2.02-2ubuntu8.26) over (2.02-2ubuntu8.25) ...
Preparing to unpack .../10-grub-pc_2.02-2ubuntu8.26_amd64.deb ...
Unpacking grub-pc (2.02-2ubuntu8.26) over (2.02-2ubuntu8.25) ...
Preparing to unpack .../11-grub-pc-bin_2.02-2ubuntu8.26_amd64.deb ...
Unpacking grub-pc-bin (2.02-2ubuntu8.26) over (2.02-2ubuntu8.25) ...
Preparing to unpack .../12-grub-common_2.02-2ubuntu8.26_amd64.deb ...
Unpacking grub-common (2.02-2ubuntu8.26) over (2.02-2ubuntu8.25) ...
Setting up python3-update-manager (1:18.04.12) ...
Setting up libefivar1:amd64 (34-1) ...
Setting up libefiboot1:amd64 (34-1) ...
Setting up ubuntu-pro-client (32.3~18.04) ...
Setting up ubuntu-advantage-tools (32.3~18.04) ...
Removing obsolete conffile /etc/ubuntu-advantage/help_data.yaml ...
Setting up update-manager-core (1:18.04.12) ...
Setting up update-notifier-common (3.192.1.21) ...
Setting up efibootmgr (15-1) ...
Setting up ubuntu-pro-client-l10n (32.3~18.04) ...
Setting up grub-common (2.02-2ubuntu8.26) ...
update-rc.d: warning: start and stop actions are no longer supported; falling ba
ck to defaults
Setting up grub-pc-bin (2.02-2ubuntu8.26) ...
Setting up grub2-common (2.02-2ubuntu8.26) ...
Setting up grub-pc (2.02-2ubuntu8.26) ...
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-curtin-settings.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-213-generic
Found initrd image: /boot/initrd.img-4.15.0-213-generic
Found linux image: /boot/vmlinuz-4.15.0-211-generic
Found initrd image: /boot/initrd.img-4.15.0-211-generic
done
Processing triggers for systemd (237-3ubuntu10.57) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for install-info (6.5.0.dfsg.1-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
不要なパッケージを削除する
依存関係がなくなり、不要となったパッケージを削除します。
コマンド実行例
$ sudo apt autoremove -y
[sudo] password for user:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libfile-copy-recursive-perl openbsd-inetd tcpd update-inetd
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 304 kB disk space will be freed.
(Reading database ... 116932 files and directories currently installed.)
Removing openbsd-inetd (0.20160825-3) ...
Removing update-inetd (4.44) ...
Removing libfile-copy-recursive-perl (0.40-1) ...
Removing tcpd (7.6.q-27) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
OSのバージョンをアップグレードする
OSのバージョンをアップグレードします。
コマンド実行例
$ sudo do-release-upgrade
[sudo] password for user:
- 以下省略-
まとめ
Linux OSのアップデート方法を紹介しました。
Linux OSのアップデートは
- updateオプションでパッケージリストを最新化
- upgradeオプションでパッケージを最新化
- autoremoveオプションで不要なパッケージを削除
OSを常に最新のものに保つことは、セキュリティの観点でも重要です。
定期的にOSアップデートを行って、最新状態に更新することを推奨します。