メインコンテンツへスキップ
  1. Linux 関連記事一覧/
  2. Ubuntu 26.04 LTS Server/

Ubuntu 26.04 LTS Server システム最適化 apt update/upgrade

目次

apt によるシステム更新

Ubuntu で標準的に利用されているソフトウェアパッケージ管理システムは APT です。システムを最新化するには、下記のコマンドを update、upgrade の順に実行します。

パッケージリストの更新(apt update)

パッケージリストの更新コマンド
sudo apt update
パッケージリストの更新(apt update) 実行例
kazu@ubuntu2604:~$ sudo apt update
[sudo: authenticate] Password:
Hit:1 http://security.ubuntu.com/ubuntu resolute-security InRelease
Hit:2 http://jp.archive.ubuntu.com/ubuntu resolute InRelease
Hit:3 http://jp.archive.ubuntu.com/ubuntu resolute-updates InRelease
Hit:4 http://jp.archive.ubuntu.com/ubuntu resolute-backports InRelease
35 packages can be upgraded. Run 'apt list --upgradable' to see them.
kazu@ubuntu2604:~$

システムパッケージの更新(apt upgrade)

システムパッケージの更新コマンド
sudo apt -y upgrade
  • -y オプションを付与することで、(Yes/No) の確認プロンプトに対してすべて自動で Y と応答します。
システムパッケージの更新(apt upgrade) 実行例
kazu@ubuntu2604:~$ sudo apt -y upgrade
[sudo: authenticate] Password:
The following packages were automatically installed and are no longer required:
  linux-headers-7.0.0-14                   linux-modules-7.0.0-14-generic
  linux-headers-7.0.0-14-generic           linux-tools-7.0.0-14
  linux-image-unsigned-7.0.0-14-generic    linux-tools-7.0.0-14-generic
  linux-main-modules-zfs-7.0.0-14-generic
Use 'sudo apt autoremove' to remove them.

Upgrading:
  base-files                        linux-firmware-qualcomm-graphics
  fwupd                             linux-firmware-qualcomm-misc
  gir1.2-packagekitglib-1.0         linux-firmware-realtek
  iproute2                          motd-news-config
  libfwupd3                         packagekit
  libgcrypt20                       python3-distupgrade
  libpackagekit-glib2-18            sg3-utils
  libsgutils2-1.48                  sg3-utils-udev
  linux-firmware-amd-misc           snapd
  linux-firmware-broadcom-wireless  ubuntu-kernel-accessories
  linux-firmware-intel-graphics     ubuntu-minimal
  linux-firmware-intel-wireless     ubuntu-release-upgrader-core
  linux-firmware-marvell-wireless   ubuntu-server
  linux-firmware-mellanox-spectrum  ubuntu-server-minimal
  linux-firmware-netronome          ubuntu-standard
  linux-firmware-nvidia-graphics    update-notifier-common
  linux-firmware-qlogic

/snip/

Processing triggers for plymouth-theme-ubuntu-text (24.004.60+git20250831.4a3c171d-0ubuntu8)Processing triggers for dracut (110-11)update-initramfs: Generating /boot/initrd.img-7.0.0-28-generic
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
kazu@ubuntu2604:~$

-y は「何がどう変更されるか」を確認するプロンプトを省略するオプションです。検証環境では手軽ですが、稼働中のサーバーでは以下の点に注意してください。

  • 更新対象を事前に確認したい場合は、apt list --upgradable で一覧を表示するか、apt upgrade --dry-runapt-get -s upgrade と同等)で実際には変更を加えずに結果だけを確認できる。
  • ライブラリが更新されると、それを使用しているサービスの再起動が必要になることがある。カーネルが更新された場合はOS自体の再起動が必要になり、再起動が必要かどうかは /var/run/reboot-required ファイルの有無で確認できる。
  • 上記の実行例の末尾に出ている Running kernel seems to be up-to-date.No services need to be restarted. は、この更新では再起動が不要だったことを示しています。ここに再起動が必要なサービス名が並ぶ場合は、影響を確認したうえで再起動のタイミングを判断してください。

参考リンク

Ubuntu Server documentation: Managing your software

関連記事

Ubuntu 公式ページ