본문 바로가기

LINUX/기초

apt(Advanced Packaging Tool) 기초 사용 설명서

리눅스에도 윈도우나 맥처럼 앱, 프로그램이 있음.

명령어로 사용했던 ls나 mv, cp 모두

리스트를 보여주는 프로그램, 이동시키는 프로그램, 복사하는 프로그램을 명령어를 통해 실행한 것.

 

근데 리눅스를 이용할 때 기본 프로그램으로는 할 수 없는 것들이 있음.

이 때 ! 다양한 프로그램을 모아둔 패키지 매니저를 이용.

즉 앱스토어나 구글플레이스토어라고 생각하면 편함.

 

데비안 - Ubuntu는 apt라는 패키지 매니저를 사용.

레드햇 - CentOS는 yum을 사용.

 

apt (Advanced Pakaging Tool)

 

 

apt의 기초인 apt-getapt-cache를 알아보자.

( apt-get랑 apt-cache를 쳐보면 도움말이 나옴)

apt-get은 패키지 설치를 담당하고, apt-cache는 패키지 검색을 담당하는 tool로

RPM 기반 배포판에서 사용되는 APT 패키지 핸들링 도구들이고

apt 최종 사용자를 위해 개발되고 apt-get 나 apt-cache 를 대체하는 high-level의 도구.

 


 

apt-get 사용법 

 

 

apt 1.2.32ubuntu0.1 (amd64) 
Usage: apt-get [options] command 
            apt-get [options] install|remove pkg1 [pkg2 ...] 
            apt-get [options] source pkg1 [pkg2 ...] 

 

apt-get is a command line interface for retrieval of packages and information about them from authenticated sources and for installation, upgrade and removal of packages together with their dependencies.

 

Most used commands: 

update - 패키지 목록을 새로 가져옵니다

upgrade - 업그레이드를 합니다 

install - 새 패키지를 설치합니다

remove - 패키지를 지웁니다 
purge - 패키지를 완전히 지웁니다 
autoremove - 사용하지 않는 패키지를 자동으로 전부 지웁니다 
dist-upgrade - 배포판 업그레이드, apt-get(8) 참고 
dselect-upgrade - dselect에서 선택한 걸 따릅니다 
build-dep - 소스 패키지의 빌드 의존성을 설정합니다 
clean - 내려받은 아카이브 파일들을 지웁니다 
autoclean - 과거에 내려받은 아카이브 파일들을 지웁니다 
check - 의존성이 망가지지 않았는지 확인합니다 
source - 소스 아카이브를 다운로드합니다 

download - Download the binary package into the current directory 
changelog - Download and display the changelog for the given package 

 


 

apt-cache 사용법

 

 

apt 1.2.32ubuntu0.1 (amd64)
Usage: apt-cache [options] command
            apt-cache [options] show pkg1 [pkg2 ...]

 

apt-cache queries and displays available information about installed and installable packages. It works exclusively on the data acquired into the local cache via the 'update' command of e.g. apt-get. The displayed information may therefore be outdated if the last update was too long ago, but in exchange apt-cache works independently of the availability of the configured sources (e.g. offline).

 

Most used commands:
  showsrc - 소스 기록을 봅니다
  search - 정규식 패턴에 맞는 패키지 목록을 찾습니다
  depends - 패키지에 대해 의존성 정보를 그대로 봅니다
  rdepends - 패키지의 역 의존성 정보를 봅니다
  show - 패키지에 대해 읽을 수 있는 기록을 봅니다
  pkgnames - 시스템에 들어 있는 패키지의 이름을 모두 봅니다
  policy - 정책 설정을 봅니다

 


 

 

우선 apt-get update 로 내 컴터에 설치가 가능한 최신 패키지 목록을 가져와보자.

 

쏼라쏼라 뜰텐데 apt에서 어떤 패키지들을 가져왔는지 확인 하고 싶다면 apt-cache pkgnames 를 입력하면 된다. 

엄청 많아서 깜짝 놀랄껄

 

패키지들을 모두 설치한 게 아니라 목록만 가져 온거임!

패키지를 이용하고 싶으면 설치해야함.

 

2. 패키지 중 하나(htop)를 설치 후 삭제도 해보자.

 

apt-cache search htop - 가져온 패키지 목록에 htop가 있는지 확인.

apt-get install htop - htop 설치

htop - 실행 (나올때는 q)

apt-get upgrade htop - htop를 최신버전으로 업그레이드

htop - 실행 (설치할 때 이미 최신버전이지만 왠지 뭔가 달라진거 같음)

apt-get remove htop - htop 삭제

 

 

 

search, install, upgrade, remove 모두 apt-cache / apt-get이 아닌 apt로도 실행 가능

 

 

패키지는 보통 설치 ~ 사용 ~ 업뎃 ~ 삭제의 주기를 가지니 위의 내용을 잘 숙지해두자.