본문 바로가기
개발/linux

linux apt, apt-get 차이, 사용법, 설명 (패키지 자동 설치 스크립트 작성 시 더 좋은 것)

by amkorousagi 2022. 10. 22.

linux apt, apt-get 차이 사용법 설명

사용하는 이유


패키지를 설치 및 관리하기 위해서입니다.

 

apt와 apt-get 차이


둘 다 근본적으로 dpkg와 같은 low-level 패키지 매니저에 대한 손쉬운 인터페이스를 제공하기 위해 만들어졌습니다.

 

apt-get 이 먼저 공개되었고 apt는 나중에 apt-get을 개선하고자 공개되었습니다.

apt는 좀 더 사용자 친화적으로 개선된 apt-get의 변형입니다.

(apt는 apt-get을 백앤드로 사용합니다.)

 

apt에서 새로 추가된 명령어들을 다음과 같습니다.

  • apt search <package name>: 레포지토리에서 패키지 이름을 찾습니다. apt-cache search와 동일합니다.
  • apt show <package name>: 패키지 정보를 보여줍니다. apt-cache show와 동일합니다.
  • apt list option : 설치되거나 업그레이드 가능한 패키지들을 보여줍니다.
  • apt edit-sources : apt에 저장된 레포지토리 리스트를 직접 수정합니다.

 

apt와 apt-get를 사용하기 전..


 

패키지를 수정해야 하기 때문에 sudo 권한을 필요로 합니다.

 

apt, apt-get 설치 / 삭제, 업데이트 / 업그레이드


sudo apt-get install <package names> # 패키지 설치
sudo apt install <package names> # 패키지 설치

sudo apt-get remove <package names> # 패키지 삭제
sudo apt remove <package names> # 패키지 삭제

sudo apt-get update # 업데이트
sudo apt update # 업데이트

sudo apt-get upgrade # 업그레이드
sudo apt upgrade # 업그레이드

업데이트 :

패키지 인덱스 파일(해당 패키지를 제공하는 소스 레포지토리 정보)을  /etc/apt/sources.list와 동기화합니다.

반드시 업그레이드 이전에 실행되어야 합니다.

 

업그레이드 :

업데이트 이후 업그레이드를 합니다. /etc/apt/source.list에 나열된 레포지토리에서 최신 패키지를 설치합니다.

단, 어떤 상황에서도 현재 설치된 패키지가 제거되지 않으며 아직 설치되지 않은 패키지도 검색 및 설치되지 않습니다. 다른 패키지의 설치 상태를 변경하지 않고는 업그레이드할 수 없는 현재 설치된 패키지의 새 버전은 현재 버전으로 유지됩니다.

 

apt, apt-get  -y, purge, autoremove


sudo apt -y install <package names> # 실행 중 질의(정말로 설치할거냐? 등)에 자동으로 yes
sudo apt purge <package names> # 패키지와 그 환경설정 모두 제거
sudo apt autoremove # 지금은 사용되지 않는 패키지 삭제

 

linux man page 설명


apt-get is the command-line tool for handling packages, and may be considered the user's "back-end" to other tools using the APT library. Several "front-end" interfaces exist, such as synaptic and aptitude.

 

APT is a management system for software packages. Originally written for Debian and the deb package format, APT was ported and became APT-RPM to manage the rpm(8) package format. APT-RPM can be used by any RPM-based distribution, such as Conectiva, Red Hat, SUSE, ALT-Linux, etc.

 

(해석)

apt-get 은 패키지를 다루기 위한 커맨드 라인 도구이며 APT 라이브러리를 사용하는 다른 도구들에서는 유저의 백엔드로 사용된다. synaptic이나 aptitude와 같은 여러 프런트엔드 인터페이스들이 존재한다.

 

APT은 소프트웨어 패키지를 위한 관리 시스템이다. 기본적으로 Debeian과 deb 패키지 형식을 위해 만들어졌지만, APT는 APT-RPM으로 이식되었고 rpm 패키지 포맷을 다루기 위해 APT-RPM이 되었다. APT-RPM은 Red Hat과 같은 RPM 기반 배포판에 의해 사용될 수 있다.

 

apt와 apt-get 중 무엇을 써야 할까?


 

평상시에는 apt를 쓰고,

패키지 설치 스크립트를 작성하는 경우 apt-get을 사용하면 좋습니다.

 

apt는 업데이트가 빠르고,

apt-get은 이식성 및 호환성이 뛰어나기 때문입니다.

 

또 apt는 명령어 실행 이후에도 y 를 누르라는 등의 사용자 입력을 요구하는 경우가 많은데, 이는 스크립트로 설치를 자동화할 때 제대로 작동하지 않는 원인이 되기도 합니다. 따라서 스크립트로 작성하는 경우 사용자 입력을 특별히 요구하지 않는 apt-get를 사용하는 편이 훨씬 낫습니다.

 

참고 자료


 

apt-get(8) - Linux man page

apt-get(8) - Linux man page Name apt-get - APT package handling utility - command-line interface Synopsis apt-get [options] [-o config=string] [-c=cfgfile] command [pkg] Description apt-get is the command-line tool for handling packages, and may be conside

linux.die.net

 

apt(8): Advanced Package Tool - Linux man page

apt(8) - Linux man page Name apt - Advanced Package Tool Description APT is a management system for software packages. Originally written for Debian and the deb package format, APT was ported and became APT-RPM to manage the rpm(8) package format. APT-RPM

linux.die.net

 

apt vs. apt-get: What’s the Difference on Linux?

Why do Debian-based Linux distributions have apt as well as apt-get? Did apt replace apt-get or do they have different purposes? We explain the relationship between these two commands.

www.howtogeek.com

 

댓글