apt update

パッケージと実行環境

書き方

sudo apt update

パッケージ一覧を取り直すだけです。これだけでは何も入らず上がらないのでapt upgradeが続き、作りたてのコンテナは一覧が空なのでまずこれを打ちます。

よく使うオプション

オプション意味
apt upgradethe second half: actually install the newer versions
apt full-upgradeallow packages to be removed to finish the upgrade
apt list --upgradableshow what the refresh found
-qquieter output for logs and CI
--allow-releaseinfo-changeaccept a repository that renamed its suite

sudo apt update

refreshes the package lists only

sudo apt update && sudo apt upgrade -y

refresh, then install the updates

apt list --upgradable

lists the packages that now have a newer version

何をどこに入れるかが問題です。このプロジェクトの中か、マシン全体かを先に決めてください。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. apt update は何をしますか。

パッケージ一覧を取り直すだけです。これだけでは何も入らず上がらないのでapt upgradeが続き、作りたてのコンテナは一覧が空なのでまずこれを打ちます。

Q. どう打ちますか。

sudo apt update — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは5個です。全部は man apt にあります。このコマンドはパッケージと実行環境の仲間です。

関連するコマンド

man ページ: man apt-update