Ubuntu パッケージのアップデート
apt-getコマンドを使ったパッケージ更新
- Ubuntu Linux環境で、apt-getコマンドを使ったパッケージ更新方法をまとめます。
apt-get update
- パッケージリストの更新(実際のアップデートは行わない)
$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [416 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [147 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [567 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [644 kB]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [183 kB]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [4008 B]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2060 B]
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [239 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [954 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [281 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [6644 B]
Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [3556 B]
Get:21 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2512 B]
Get:22 http://archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [1644 B]
Get:23 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [3712 B]
Get:24 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1696 B]
Fetched 17.3 MB in 1min 56s (150 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
49 packages can be upgraded. Run 'apt list --upgradable' to see them.
apt-get upgrade
- インストールされているパッケージのアップデート
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
apt-get autoremove
- 依存関係が変わり不要となったパッケージの削除
$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libfreetype6
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 940 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 28657 files and directories currently installed.)
Removing libfreetype6:amd64 (2.8.1-2ubuntu2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
apt-get dist-upgrade
- Kernelを含むディストリビューションのアップデート
- インストールされているパッケージだけでなく、新たに必要なパッケージのインストールや不要となったパッケージの削除も行うコマンド。
$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
libfreetype6
Use 'sudo apt autoremove' to remove it.
The following packages will be upgraded:
apt apt-utils cloud-init curl dbus gcc-8-base initramfs-tools initramfs-tools-bin initramfs-tools-core
libapt-inst2.0 libapt-pkg5.0 libcurl3-gnutls libcurl4 libdb5.3 libdbus-1-3 libelf1 libgcc1 libglib2.0-0
libglib2.0-data libgnutls30 libnss-systemd libpam-systemd libpython3.6 libpython3.6-minimal libpython3.6-stdlib
libseccomp2 libssl1.1 libstdc++6 libsystemd0 libudev1 openssl python3-cryptography python3-distupgrade python3-gdbm
python3-jinja2 python3-software-properties python3.6 python3.6-minimal software-properties-common systemd
systemd-sysv ubuntu-release-upgrader-core udev update-notifier-common vim vim-common vim-runtime vim-tiny xxd
49 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 26.4 MB of archives.
After this operation, 839 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
** snip **
- パッケージのアップデート中にサービスの再起動が必要な場合のメッセージ
Services restarted successfully.
Setting up python3-jinja2 (2.10-1ubuntu0.18.04.1) ...
Setting up openssl (1.1.1-1ubuntu2.1~18.04.2) ...
Installing new version of config file /etc/ssl/openssl.cnf ...
Setting up vim-common (2:8.0.1453-1ubuntu1.1) ...
Setting up python3-gdbm:amd64 (3.6.8-1~18.04) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up python3-software-properties (0.96.24.32.9) ...
Setting up vim-runtime (2:8.0.1453-1ubuntu1.1) ...
Setting up initramfs-tools-bin (0.130ubuntu3.8) ...
Processing triggers for rsyslog (8.32.0-1ubuntu4) ...
invoke-rc.d: could not determine current runlevel
Setting up libdbus-1-3:amd64 (1.12.2-1ubuntu1.1) ...
Setting up python3-distupgrade (1:18.04.33) ...
Setting up cloud-init (19.1-1-gbaa47854-0ubuntu1~18.04.1) ...
Installing new version of config file /etc/cloud/cloud.cfg ...
Setting up software-properties-common (0.96.24.32.9) ...
Setting up python3-cryptography (2.1.4-1ubuntu1.3) ...
Setting up vim-tiny (2:8.0.1453-1ubuntu1.1) ...
W: APT had planned for dpkg to do more than it reported back (217 vs 246).
Affected packages: curl:amd64 dbus:amd64 initramfs-tools-core:amd64 initramfs-tools:amd64 libcurl4:amd64 libpam-systemd:amd64 libpython3.6-minimal:amd64 libpython3.6-stdlib:amd64 libpython3.6:amd64 python3.6-minimal:amd64 python3.6:amd64 ubuntu-release-upgrader-core:amd64 vim-tiny:amd64 vim:amd64
Posted by takaaki