パッケージマネージャのコマンドがディストリビューションで微妙に違ってて覚えられないのでメモ。

  • pkgを使うのはFreeBSD
  • aptを使うのはDebian, Ubuntu (一部dpkgも使う)
  • dnfを使うのはFedora, RHEL, CentOS
  • apkを使うのはAlpine Linux
  • wingetを使うのはWindows

リポジトリを近くのミラーに変更

  • (pkgは自動で近場につないでくれるので不要)
  • aptsed -i.org -e 's#//archive#//jp.archive#' /etc/apt/sources.list とか
  • (dnfは自動で近場につないでくれるので不要)
  • apkはデフォルトのdl-cdn.alpinelinux.orgで十分速いので基本不要だが、やるなら apk add alpine-conf && setup-apkrepos
  • (wingetは今のところリポジトリが1つしかない)

パッケージリストの最新化

  • (pkgは自動で最新化するので不要だが、手動でやるならpkg update)
  • apt update
  • (dnfは自動で最新化するので不要だが、何かで最新化するならdnf check-updateとか)
  • apk update
  • (wingetは常に最新のリストを見ていると思われる)

検索

  • pkg search xxx
  • apt search xxxapt list '*xxx*'
  • dnf search xxxdnf list '*xxx*'
  • apk search xxxapk list '*xxx*'
  • winget search xxx

インストール

  • pkg install xxx
  • apt install xxx
  • dnf install xxx
  • apk add xxx
  • winget install xxxwinget add xxx

削除(そのパッケージだけ)

  • pkg delete xxx
  • apt remove xxx か、設定も消すなら apt purge xxx
  • dnf remove --noautoremove xxx
  • (apkではできない)
  • winget uninstall xxxwinget remove xxx

削除(依存先も一緒に)

  • pkg delete xxx && pkg autoremove
  • apt remove --auto-remove xxx か、設定も消すなら apt purge --auto-remove xxx
  • dnf remove xxx
  • apk del xxx か、設定も消すなら apk del --purge xxx
  • (wingetではできない)

全パッケージを更新

  • pkg upgrade
  • apt upgrade か、削除も許すなら apt full-upgrade
  • dnf upgrade
  • apk upgrade
  • winget upgrade --allwinget update --all

インストールされているパッケージ一覧

  • pkg info
  • apt list --installeddpkg -l
  • dnf list --installed
  • apk list -Iapk info
  • winget list

明示的にインストールしたパッケージ一覧(依存で入ったやつは除外)

  • pkg prime-list
  • (aptではできない)
  • dnf history で追うか、dnf install 'dnf-command(leaves)' してから dnf leaves
  • (apkではできない)
  • (wingetでは今のところ依存関係を管理していない)

説明

  • pkg info xxx
  • apt info xxxapt show xxx
  • dnf info xxx
  • apk info xxx
  • winget show xxxwinget view xxx

何に依存しているか

  • pkg info -d xxx
  • apt depends xxx
  • dnf deplist xxx
  • apk info -R xxx
  • (wingetでは今のところ依存関係を管理していない)

何から依存されているか

  • pkg info -r xxx
  • apt rdepends xxx
  • dnf repoquery --whatdepends xxx
  • apk info -r xxx
  • (wingetでは今のところ依存関係を管理していない)

そのパッケージが入れたファイル一覧

  • pkg info -l xxx
  • dpkg -L xxx
  • dnf repoquery -l xxx
  • apk info -L xxx
  • (wingetではできない)

そのファイルを入れたパッケージ

  • pkg which /path/to/the/file
  • dpkg -S /path/to/the/file
  • dnf provides /path/to/the/file
  • apk info -W /path/to/the/file
  • (wingetではできない)

キャッシュ削除

  • pkg clean
  • apt clean
  • dnf clean all
  • rm -rf /var/cache/apk/*
  • (wingetではできない)

※バージョンメモ

  • FreeBSD 13.0-RELEASE
  • Ubuntu 20.04
  • CentOS 8.3
  • Alpine Linux 3.13
  • Windows 11 Pro 22H2

※更新履歴

  • 2023-05-12 wingetを追加。