テクノロジーガイド

Apt sources.list の設定方法 — 完全初心者向け

2 min read Linux 更新されました 18 Oct 2025
Apt sources.list を修復・設定する方法
Apt sources.list を修復・設定する方法

目的と対象読者

このガイドは、Ubuntu/Debian 系ディストリビューションで apt の sources.list を編集・復元したい「完全初心者」を対象としています。ターミナルでの基本コマンドが使えることを前提とします。

重要: sources.list はシステムがどこからパッケージを取得するかを決める重要なファイルです。編集前に必ずバックアップを作成してください。

準備: 用語の一行定義

  • sources.list: apt が参照するリポジトリ一覧ファイル。場所は /etc/apt/sources.list
  • apt-get update: リポジトリ情報を再取得するコマンド

使い方の概要(手順)

  1. 新しい sources.list を用意する(ウェブ生成ツールや配布元のサンプルを使用)。
  2. 現在のファイルをバックアップする。
  3. 新しい内容を /etc/apt/sources.list に貼り付ける。
  4. apt-get update を実行して動作確認する。

元の sources.list の例

下のブロックは、よくある sources.list の中身(例)をそのまま示しています。必要ならここからコピーして編集してください。

| # deb cdrom:[Ubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016)]/ gutsy main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. # Line commented out by installer because it failed to verify: # deb http://ie.archive.ubuntu.com/ubuntu/ gutsy main restricted # Line commented out by installer because it failed to verify: # deb-src http://ie.archive.ubuntu.com/ubuntu/ gutsy main restricted ## Major bug fix updates produced after the final release of the ## distribution. # Line commented out by installer because it failed to verify: # deb http://ie.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted # Line commented out by installer because it failed to verify: # deb-src http://ie.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## universe WILL NOT receive any review or updates from the Ubuntu security ## team. # Line commented out by installer because it failed to verify: # deb http://ie.archive.ubuntu.com/ubuntu/ gutsy universe # Line commented out by installer because it failed to verify: # deb-src http://ie.archive.ubuntu.com/ubuntu/ gutsy universe # Line commented out by installer because it failed to verify: # deb http://ie.archive.ubuntu.com/ubuntu/ gutsy-updates universe # Line commented out by installer because it failed to verify: # deb-src http://ie.archive.ubuntu.com/ubuntu/ gutsy-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. # Line commented out by installer because it failed to verify: # deb http://ie.archive.ubuntu.com/ubuntu/ gutsy multiverse # Line commented out by installer because it failed to verify: # deb-src http://ie.archive.ubuntu.com/ubuntu/ gutsy multiverse # Line commented out by installer because it failed to verify: # deb http://ie.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse # Line commented out by installer because it failed to verify: # deb-src http://ie.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse ## Uncomment the following two lines to add software from the 'backports' ## repository. ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. # deb http://ie.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse # deb-src http://ie.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. This software is not part of Ubuntu, but is ## offered by Canonical and the respective vendors as a service to Ubuntu ## users. deb http://archive.canonical.com/ubuntu hardy partner deb-src http://archive.canonical.com/ubuntu hardy partner # Line commented out by installer because it failed to verify: # deb http://security.ubuntu.com/ubuntu gutsy-security main restricted # Line commented out by installer because it failed to verify: # deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted # Line commented out by installer because it failed to verify: # deb http://security.ubuntu.com/ubuntu gutsy-security universe # Line commented out by installer because it failed to verify: # deb-src http://security.ubuntu.com/ubuntu gutsy-security universe # Line commented out by installer because it failed to verify: # deb http://security.ubuntu.com/ubuntu gutsy-security multiverse # Line commented out by installer because it failed to verify: deb http://archive.ubuntu.com/ubuntu/ hardy main universe restricted multiverse deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe main restricted multiverse deb http://security.ubuntu.com/ubuntu/ hardy-security universe main restricted multiverse # deb-src http://security.ubuntu.com/ubuntu gutsy-security multiverse # deb http://download.tuxfamily.org/syzygy42 gutsy avant-window-navigator # deb-src http://download.tuxfamily.org/syzygy42 gutsy avant-window-navigator # deb http://archive.ubuntustudio.org/ubuntustudio edgy main |

実際の復元手順(コマンド)

次の例はターミナルでの安全な手順です。1行ずつ実行してください。

  • まず現在の sources.list をバックアップします。
sudo mv /etc/apt/sources.list /etc/apt/sources.list.old
sudo touch /etc/apt/sources.list
sudo vim /etc/apt/sources.list
  • vim が使えない場合は nano でも構いません:
sudo nano /etc/apt/sources.list
  • vim での貼り付け手順(基本):

    1. vim を開いたら i キーで挿入モードに入る。
    2. マウスの右クリックやターミナルの貼り付け機能でクリップボード内容を貼り付ける。
    3. Esc を押した後、:wq と入力して保存して終了する。
  • 保存後、リポジトリ情報を更新します:

sudo apt-get update

よくあるエラーと対処法

  • GPG エラー、署名の検証に失敗する:

    • インターネット接続を確認する。
    • 古い/無効なリポジトリを sources.list からコメントアウトする。
    • 必要なら公開鍵(apt-key)を追加する。ただし apt-key は将来的に非推奨なので、キーの追加はリポジトリの公式手順に従って行ってください。
  • 404 エラー(パッケージが見つからない):

    • ディストリビューションのコードネーム(例: focal, bionic, jammy)が古い可能性があります。配布元の正しいコードネームに置き換えるか、公式ミラーを使用してください。
  • apt-get update が遅い/タイムアウトする:

    • ローカルのミラーや近い地域のミラー URL を使用する。
    • /etc/apt/sources.list.d/ に分割して管理する方法も検討する。

代替アプローチ

  • GUI を使う: Ubuntu 系なら「ソフトウェアと更新」アプリ(software-properties-gtk)でリポジトリを管理できます。
  • sources.list を直接編集する代わりに /etc/apt/sources.list.d/*.list に個別ファイルを置き、機能ごとに分離する。
  • 新しいリポジトリ生成サイトや公式ドキュメントから最新のサンプルをダウンロードする。

安全のためのチェックリスト(ロール別)

  • 管理者(自分):
    • 作業前に /etc/apt/sources.list のバックアップを取った
    • 信頼できるリポジトリのみを追加した
    • 変更後に sudo apt-get update を実行した
  • サポート担当:
    • ログ(/var/log/apt/)を確認して失敗の原因を特定
    • 必要なら以前のバックアップにロールバックする

ミニ・トラブルシュート方法

  1. update でエラーが出たらエラーメッセージを精査する(404/401/GPG)。
  2. エラーメッセージに基づいて該当行を一時的にコメントアウトする。
  3. 再度 sudo apt-get update を実行し、進行状況を確認する。

重要: 変更を加えるときは最小限の差分で試し、確実に動作することを確認してから他の行を編集してください。

まとめ

  • sources.list を編集する前に必ずバックアップを取る。
  • 新しいリポジトリを貼り付けたら sudo apt-get update を実行して動作確認する。
  • GUI や /etc/apt/sources.list.d/ を活用すれば管理が楽になる。

Критерии приёмки

  • 新しい sources.list を適用後、sudo apt-get update がエラーなく完了すること。
  • インストールしたいパッケージが apt install で取得できること。

1行用語集

  • apt: Debian 系でパッケージ管理するコマンド群の総称。
共有する: X/Twitter Facebook LinkedIn Telegram
著者
編集

類似の素材

WindowsでTeamsのエラーcaa70004を修正する方法
トラブルシューティング

WindowsでTeamsのエラーcaa70004を修正する方法

Androidでジェスチャー入力を無効にする方法
Android

Androidでジェスチャー入力を無効にする方法

Windows 10でgdi32full.dllエラーを安全に修復する方法
Windows トラブル

Windows 10でgdi32full.dllエラーを安全に修復する方法

Netflixのプロフィール画像をカスタムやGIFにする方法
How-to

Netflixのプロフィール画像をカスタムやGIFにする方法

Odin用イメージをOdinフラッシュ可能に変換する方法
ガイド

Odin用イメージをOdinフラッシュ可能に変換する方法

TikTokで動画をバズらせる方法
ソーシャルメディア

TikTokで動画をバズらせる方法