あまブログ

ドキドキ......ドキドキ2択クイ〜〜〜〜〜〜〜ズ!!

【apt install】Debian公式リポジトリに登録されていないパッケージをインストールする方法

本稿では、aptコマンドを使ってDebianの標準以外のパッケージをインストールする方法を紹介します。

1. はじめに

Debianにパッケージをインストールする時には、aptコマンドを使うことが多いと思います。

デフォルトの状態ではDebianの公式リポジトリのみが/etc/apt/sources.listに設定されています。

そのため、サードパーティ製のパッケージ(Debianの公式リポジトリに登録されていないパッケージ)をインストールするためには、そのパッケージが格納されてるリポジトリ/etc/apt/sources.listに追加する必要があります。

今回は、以下の記事を参考にiozone3のインストールを例に手順を解説します。

2. 実行環境

Debian GNU/Linux 11 (bullseye)

3. 手順

3-1.パッケージディレクトリを検索

以下のサイトから、インストールしたいパッケージが存在するリポジトリを検索します。

www.debian.org

「キーワード」にiozone3と入力して「検索」。

iozone3non-freeリポジトリにあることがわかる。

3-2.リポジトリを追加

/etc/apt/sources.listnon-freeリポジトリを追加します。

今回はリポジトリの追加にapt-add-repositoryコマンドを使用します(sources.listを自分で直接編集する方法もある)。

apt-add-repositoryコマンドを使用するにはsoftware-properties-commonパッケージが必要です。

以下のコマンドを実行して、software-properties-commonパッケージをインストールします。

$ apt install -y software-properties-common

※上記コマンドの-yオプションについて、以下apt-getのmanpageより抜粋

-y, --yes, --assume-yes

Automatic yes to prompts; assume "yes" as answer to all prompts and run non-interactively.

If an undesirable situation, such as changing a held package, trying to install an unauthenticated package or removing an essential package occurs then apt-get will abort.

Configuration Item: APT::Get::Assume-Yes.

次に、以下のコマンドを実行して/etc/apt/sources.listnon-freeリポジトリを追加します。

$ apt-add-repository non-free

以下の/etc/apt/sources.listnon-freeリポジトリが追加されたことがわかります。

# deb http://ftp.jp.debian.org/debian bullseye main

deb http://ftp.jp.debian.org/debian bullseye main non-free
deb-src http://ftp.jp.debian.org/debian bullseye main non-free

deb http://security.debian.org/debian-security bullseye-security main non-free
deb-src http://security.debian.org/debian-security bullseye-security main non-free

3-3.パッケージをインストール

最後にiozone3をインストールします。

$ apt update
$ apt install -y iozone3

以上です。


【参考】