Ubuntu 14 이상은 apt-get 대신 apt 명령어 사용을 권장하고 있습니다.

Red Hat 의 yum 명령어와 비교는 Ubuntu apt(apt-get) 와 Redhat/CentOS yum 명령어 비교표 를 참고하세요

apt-get

Index update

등록한 저장소내 전체 패키지 인덱스 업데이트

sudo apt-get update
CODE

전체 패키지 update (yum update)

sudo apt-get upgrade
CODE


의존성 검사하며 업그레이드

sudo apt-get dist-upgrade
CODE


설치

설치 (yum install)

sudo apt-get install package-name

sudo apt-get install gcc
CODE

재설치 (yum reinstall)

apt-get --reinstall install package-name

sudo apt-get --reinstall install gcc
CODE


삭제

remove - 패키지만 삭제

설정파일은 지우지 않으며 sudo apt-get remove  package-name 와 같은 형식으로 사용

sudo apt-get remove gcc
CODE


purge - config도 삭제

설정파일도 삭제하므로 주의해서 사용. sudo apt-get purge  package-name

sudo apt-get purge gcc
CODE


검색

패키지 검색은 apt-cache 명령어를 사용

search - 패키지 검색

sudo apt-cache search package-name

sudo apt-cache search php7
CODE

확장 검색

This will find packages whose names contain <search_term>. Similar to apt-cache search, but also shows whether a package is installed on your system by marking it with ii (installed) and un (not installed).

dpkg -l *패키지이름*
CODE


설치된 전체 패키지 보기 (yum list installed)

yum list installed 처럼 현재 시스템에 설치된 전체 패키지 정보 보기

Ubuntu 14 이상은 apt 명령어로 간단하게 처리 가능

apt list --installed
CODE


특정 패키지 설치 여부 확인

apt -qq list gcc
CODE


예전 버전의 ubuntu 사용시 debian 의 dpkg 명령 사용

dpkg --get-selections | grep -v deinstall
CODE

특정 패키지 설치 여부 확인

dpkg --get-selections | grep postgres
CODE


패키지 정보 보기 (yum info)

$ apt-cache show 패키지이름
CODE
$ apt-cache show php5-fpm
 
Package: php5-fpm
Priority: optional
Section: universe/php
Installed-Size: 9035
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Architecture: amd64
Source: php5
Version: 5.5.9+dfsg-1ubuntu4.9
Depends: libbz2-1.0, libc6 (>= 2.15), libdb5.3, libpcre3, libssl1.0.0 (>= 1.0.0), libsystemd-daemon0 (>= 31), libxml2 (>= 2.9.0), zlib1g (>= 1:1.1.4), sysv-rc (>= 2.88dsf-24) | file-rc (>= 0.8.16), mime-support, php5-common (= 5.5.9+dfsg-1ubuntu4.9), libmagic1, ucf, tzdata
Pre-Depends: dpkg (>= 1.15.7.2~)
Suggests: php-pear
CODE

apt-file 

apt-file - APT package searching utility -- command-line interface

apt-file 설치

apt-file 이 없을 경우 아래 명령어로 설치기본 패키지

sudo apt install apt-file
CODE


cache 설치

"E: The cache is empty. You need to run 'apt-file update' first." 같은 에러 메시지 출력시 캐시 파일 설치

sudo apt-file update
CODE


파일이 속한 패키지 찾기 (yum provides)

yum provides 명령어처럼 파일이 속한 패키지를 찾기. 아래는 lsof 파일이 포함된 패키지 목록 출력

sudo apt-file search lsof
CODE


너무 많은 목록이 출력될 경우 파일명을 절대 경로로 입력해서 필터링 가능

sudo apt-file search /usr/bin/lsof
CODE



Ref