4.

Linuxパッケージリポジトリ一覧の確認方法(yum / dnf / apt / zypper コマンドまとめ)

編集
この記事の要点
  • yum/dnf: yum repolist all / dnf repolist --all ですべてのリポジトリ(有効/無効)を一覧
  • apt (Debian/Ubuntu): apt-cache policy または cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list
  • zypper (openSUSE/SLES): zypper repos (短縮 zypper lr)
  • 有効リポジトリだけ見たい場合: yum repolist enabled / dnf repolist --enabled
  • リポジトリ定義ファイルは /etc/yum.repos.d/*.repo (RHEL系) / /etc/apt/sources.list.d/ (Debian系) に格納

RHEL系 (yum / dnf)

すべてのリポジトリを表示

# yum (RHEL7 / CentOS7)
yum repolist all

# dnf (RHEL8+ / Fedora / Rocky / AlmaLinux)
dnf repolist --all

有効リポジトリだけ表示

yum repolist enabled       # yum
dnf repolist --enabled     # dnf
dnf repolist               # 省略時も enabled 相当

無効リポジトリだけ表示

yum repolist disabled
dnf repolist --disabled

出力例

$ dnf repolist --all
repo id              repo name                            status
appstream            Rocky Linux 9 - AppStream            enabled
appstream-debug      Rocky Linux 9 - AppStream - Debug    disabled
baseos               Rocky Linux 9 - BaseOS               enabled
epel                 Extra Packages for Enterprise Linux  enabled
extras               Rocky Linux 9 - Extras               enabled

リポジトリ定義ファイル

RHEL系では /etc/yum.repos.d/*.repo に各リポジトリの設定が置かれています。

ls /etc/yum.repos.d/
cat /etc/yum.repos.d/rocky.repo

Debian/Ubuntu (apt)

すべてのリポジトリ情報を表示

# 各パッケージの取得元と優先度
apt-cache policy

# sources.list を直接見る
cat /etc/apt/sources.list
ls /etc/apt/sources.list.d/
cat /etc/apt/sources.list.d/*.list

有効/設定中の sources を整形表示

grep -rhE '^deb ' /etc/apt/sources.list /etc/apt/sources.list.d/

PPA (Personal Package Archive) の確認

# 追加された PPA は sources.list.d/ 配下にファイルが置かれる
ls /etc/apt/sources.list.d/ | grep ppa

openSUSE / SLES (zypper)

zypper repos      # 一覧
zypper lr         # 短縮形
zypper lr -d      # URL を含めた詳細
zypper lr -u      # URI 表示

コマンド早見表

ディストリパッケージ管理一覧コマンド定義ファイル
RHEL7 / CentOS7yumyum repolist all/etc/yum.repos.d/*.repo
RHEL8+ / Fedora / Rocky / Almadnfdnf repolist --all/etc/yum.repos.d/*.repo
Debian / Ubuntuaptapt-cache policy/etc/apt/sources.list*
openSUSE / SLESzypperzypper lr/etc/zypp/repos.d/*.repo
Arch Linuxpacmancat /etc/pacman.conf/etc/pacman.conf

関連操作

  • リポジトリの有効化: dnf config-manager --set-enabled epel
  • リポジトリの無効化: dnf config-manager --set-disabled epel
  • キャッシュクリア: yum clean all / dnf clean all / apt clean
  • メタデータ更新: dnf makecache / apt update
編集
Post Share
子ページ

子ページはありません

同階層のページ
  1. ディストリビューション
  2. コマンド一覧
  3. Linuxのサーバーに登録されているユーザの一覧を確認するコマンド
  4. リポジトリの一覧の確認
  5. エラー一覧
  6. ショートカットキー一覧
  7. ログを確認する便利なコマンド
  8. cronの導入と実行方法 (CentOS 7編)
  9. ディレクトリ内のファイル数を確認
  10. 複数ファイル内の文字列を一括置換する方法