Apt sources.list 구성 방법 — 초보자 가이드
왜 이 글이 필요한가
Apt sources.list는 패키지 저장소 위치를 정의합니다. 이 파일이 손상되거나 잘못 설정되면 패키지 설치, 업데이트에서 오류가 발생합니다. 해결책은 소스 목록을 올바르게 재생성하고 apt 캐시를 갱신하는 것입니다.
중요: 먼저 현재 파일을 백업하세요. 복구 실패 시 원래 상태로 되돌릴 수 있어야 합니다.
빠른 해결책: Source-O-Matic 사용
Aptitude Source-O-Matic을 사용하면 세 가지 입력만으로 새 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
|
실제 적용 순서
- 웹에서 새 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에서 i 키를 눌러 입력 모드로 전환
- 마우스 오른쪽 클릭(또는 터미널의 붙여넣기)으로 클립보드 내용을 붙여넣기
- [ESC]를 누른 뒤 :wq 로 저장하고 종료
변경 후 apt 인덱스를 갱신합니다:
sudo apt-get update
이제 패키지 설치/업데이트가 정상적으로 동작하는지 확인하세요.
언제 이 방법이 실패하는가
- 네트워크 차단이나 프록시가 있어 외부 저장소에 접속할 수 없을 때
- 저장소가 오래되어 더 이상 존재하지 않는 릴리스(예: 매우 오래된 Ubuntu 릴리스)를 참조할 때
- 인증 키(GPG)가 누락되어 저장소 서명이 실패할 때
해결 방법: 네트워크 설정과 프록시를 점검하고, EOL(지원 종료) 릴리스를 사용하는 경우 아카이브 미러(archive.ubuntu.com 등)를 사용합니다. GPG 오류는 공개 키를 받아서 apt-key 또는 신뢰 저장소에 추가해야 합니다.
대체 방법
- 직접 sources.list를 텍스트로 작성 후 scp/ftp로 전송
- SSH 접속만 가능한 경우 echo와 리디렉션으로 파일 작성: sudo tee /etc/apt/sources.list
- 구성 관리 도구 사용: Ansible, Puppet 등으로 중앙에서 배포
역할별 체크리스트
- 초보자
- 파일 백업을 반드시 수행한다
- 한 줄씩 붙여넣어 오류가 있는지 확인한다
- 시스템 관리자
- 저장소 접근성 및 인증 키 자동화 적용
- 모니터링으로 apt 업데이트 실패 경고 설정
간단한 절차표(작업 SOP)
- 백업: sudo cp /etc/apt/sources.list /etc/apt/sources.list.YYYYMMDD
- 생성: 웹 생성기 또는 템플릿으로 sources.list 준비
- 배포: sudo mv 새파일 /etc/apt/sources.list
- 갱신: sudo apt-get update
- 검증: sudo apt-get upgrade –simulate
의사결정 흐름
flowchart TD
A[sources.list 오류 발생] --> B{네트워크 접근 가능?}
B -- Yes --> C{릴리스가 EOL인가?}
B -- No --> D[네트워크/프록시 확인]
C -- Yes --> E[아카이브 미러로 변경]
C -- No --> F[Source-O-Matic로 새 목록 생성 후 배포]
F --> G[apt-get update 실행]
G --> H{오류 발생?}
H -- Yes --> I[로그 확인 및 GPG/URL 수정]
H -- No --> J[정상]
1줄 용어 사전
- sources.list: Apt가 참조하는 저장소 목록 파일
- deb: 바이너리 패키지 저장소를 뜻하는 라인 타입
- deb-src: 소스 패키지 저장소를 뜻하는 라인 타입
- apt-get update: 저장소 색인을 갱신하는 명령
중요: 시스템에 민감한 변경을 적용하기 전에 항상 백업을 보관하세요.
요약
- sources.list가 손상되면 웹 생성기나 텍스트 편집으로 새 목록을 만들어 교체하면 복구가 쉽습니다.
- 백업, 네트워크 확인, GPG 키 점검을 반드시 수행하세요.
- 대규모 환경에서는 구성 관리 도구로 중앙 관리하는 것이 최선입니다.
참고: 때로는 SSH 터미널(특히 Windows에서) 환경 때문에 복사-붙여넣기가 다르게 동작할 수 있습니다. 이 경우 scp나 rsync로 파일을 전송하는 방법을 고려하세요.