웹사이트 검색

Ubuntu 18.04 LTS에서 APT로 패키지를 관리하는 방법


이 페이지에서

  1. 요구 사항\n
  2. 패키지 설치 및 업데이트
  3. Apt로 패키지 제거
  4. Apt-Cache로 패키지 검색
  5. APT 고급 사용

고급 패키징 도구라고도 하는 APT는 Ubuntu 16.04, Ubuntu 18.04, Debian 8, Debian 9 등과 같은 Debian 기반 배포판에서 패키지를 관리하기 위한 명령줄 도구입니다. APT는 패키지 설치, 제거, 업그레이드 프로세스를 단순화하고 명령줄 인터페이스를 통해 전체 운영 체제를 업그레이드하는 데 사용됩니다.

이 튜토리얼에서는 Ubuntu 18.04 LTS 서버에서 APT 명령줄 도구를 사용하여 패키지를 관리하는 방법을 설명합니다.

요구 사항

  • Ubuntu 18.04 LTS를 실행하는 서버.\n
  • 서버의 루트 또는 sudo 액세스.

아래의 모든 명령은 루트 사용자로 실행됩니다. 쉘에서 루트 사용자로 로그인하거나 다음을 실행하십시오.

sudo -s

루트 사용자가 되기 위해. 또는 모든 명령 앞에 sudo를 추가할 수 있습니다.

패키지 설치 및 업데이트

Apt-get은 다양한 소스에서 정보를 가져와서 로컬 데이터베이스에 저장하는 방식으로 작동합니다. 업데이트 명령어는 해당 위치에서 패키지를 가져오고 패키지를 최신 버전으로 업데이트합니다.

apt-get update -y

위 명령을 실행한 후 데이터베이스가 최신 상태여야 합니다.

업그레이드 명령은 현재 설치된 모든 소프트웨어 패키지를 최신 버전으로 업그레이드하는 데 사용됩니다.

apt-get upgrade -y

dist-upgrade 명령을 사용하여 패키지를 업그레이드할 수도 있지만 스마트 충돌 해결 방법으로 패키지 종속성을 변경합니다.

apt-get dist-upgrade -y

데이터베이스가 업데이트되면 다음 명령을 실행하여 모든 패키지를 설치할 수 있습니다.

apt-get install package1 package2

예를 들어 다음 명령을 실행하여 Nginx 웹 서버 패키지를 설치할 수 있습니다.

apt-get install nginx

패키지 파일만 다운로드하고 설치하지 않으려면 다음 명령을 실행할 수 있습니다.

apt-get install -d package1

위의 명령은 /var/cache/apt/archives 디렉토리에 패키지 파일을 다운로드합니다.

최신 버전으로 패키지를 다시 설치하려면 다음 명령을 실행하십시오.

apt-get install package1 --reinstall

Apt로 패키지 제거

시스템에서 패키지를 제거하려면 다음 명령을 실행하십시오.

apt-get remove package1

위의 명령은 패키지만 제거하고 구성 파일은 유지합니다.

다음 명령을 사용하여 구성 파일이 포함된 패키지를 제거하려면:

apt-get purge package1

다음 명령을 사용하여 원하지 않는 모든 패키지를 제거하고 데이터베이스를 정리할 수도 있습니다.

apt-get autoremove
apt-get clean

Apt-Cache로 패키지 검색

apt-cache 명령은 소프트웨어 패키지를 검색하는 데 사용됩니다.

설명으로 패키지를 찾으려면 다음 명령어를 실행하세요.

apt-cache search proftpd

다음 출력이 표시되어야 합니다.

resource-agents - Cluster Resource Agents
fail2ban - ban hosts that cause multiple authentication errors
ftpd - File Transfer Protocol (FTP) server
gadmin-proftpd - GTK+ configuration tool for proftpd
gadmin-proftpd-dbg - GTK+ configuration tool for proftpd debug package
gadmintools - GTK+ server administration tools (meta-package)
proftpd-basic - Versatile, virtual-hosting FTP daemon - binaries
proftpd-dev - Versatile, virtual-hosting FTP daemon - development files
proftpd-doc - Versatile, virtual-hosting FTP daemon - documentation
proftpd-mod-autohost - ProFTPD module mod_autohost
proftpd-mod-case - ProFTPD module mod_case
proftpd-mod-clamav - ProFTPD module mod_clamav
proftpd-mod-dnsbl - ProFTPD module mod_dnsbl
proftpd-mod-fsync - ProFTPD module mod_fsync
proftpd-mod-geoip - Versatile, virtual-hosting FTP daemon - GeoIP module
proftpd-mod-ldap - Versatile, virtual-hosting FTP daemon - LDAP module
proftpd-mod-msg - ProFTPD module mod_msg
proftpd-mod-mysql - Versatile, virtual-hosting FTP daemon - MySQL module
proftpd-mod-odbc - Versatile, virtual-hosting FTP daemon - ODBC module
proftpd-mod-pgsql - Versatile, virtual-hosting FTP daemon - PostgreSQL module
proftpd-mod-sqlite - Versatile, virtual-hosting FTP daemon - SQLite3 module
proftpd-mod-tar - ProFTPD module mod_tar
proftpd-mod-vroot - ProFTPD module mod_vroot

다음 명령을 사용하여 proftpd로 시작하는 모든 패키지를 찾으십시오.

apt-cache pkgnames proftpd

다음 출력이 표시되어야 합니다.

apt-cache pkgnames proftpd
proftpd-mod-dnsbl
proftpd-mod-odbc
proftpd-mod-pgsql
proftpd-doc
proftpd-mod-tar
proftpd-mod-ldap
proftpd-mod-case
proftpd-mod-geoip
proftpd-mod-mysql
proftpd-basic
proftpd-mod-vroot
proftpd-mod-clamav
proftpd-mod-autohost
proftpd-mod-fsync
proftpd-mod-sqlite
proftpd-mod-msg
proftpd-dev

다음 명령을 사용하여 모든 패키지(nano)의 전체 정보를 확인할 수 있습니다.

apt-cache show nano

산출:

Package: nano
Priority: standard
Section: editors
Installed-Size: 600
Maintainer: Ubuntu Developers <>
Original-Maintainer: Jordi Mallach <>
Architecture: amd64
Version: 2.2.6-1ubuntu1
Replaces: pico
Provides: editor
Depends: libc6 (>= 2.14), libncursesw5 (>= 5.6+20070908), libtinfo5, dpkg (>= 1.15.4) | install-info
Suggests: spell
Conflicts: pico
Breaks: alpine-pico (<= 2.00+dfsg-5)
Filename: pool/main/n/nano/nano_2.2.6-1ubuntu1_amd64.deb
Size: 194060
MD5sum: c97dc062e9941bfe13b6b303cf8ed639
SHA1: ee93fcfd1f2ecd601b0a8f8932319848043f4f0f
SHA256: f20d8cca5c30b90ebf68301d126f86e473ac83e7d6fdc36f59bcd685c2eb4020
Description-en: small, friendly text editor inspired by Pico
 GNU nano is an easy-to-use text editor originally designed as a replacement
 for Pico, the ncurses-based editor from the non-free mailer package Pine
 (itself now available under the Apache License as Alpine).
 .
 However, nano also implements many features missing in pico, including:
  - feature toggles;
  - interactive search and replace (with regular expression support);
  - go to line (and column) command;
  - auto-indentation and color syntax-highlighting;
  - filename tab-completion and support for multiple buffers;
  - full internationalization support.
Description-md5: b7e1d8c3d831118724cfe8ea3996b595
Homepage: http://www.nano-editor.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: standard, kubuntu-active, kubuntu-active

다음 명령을 사용하여 특정 패키지의 종속성을 확인하려면:

apt-cache showpkg htop

산출:

Package: htop
Versions: 
2.1.0-3 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_binary-amd64_Packages
                  MD5: 8eb5aa19b3c92a975dc78e2165f6688d
 Description Language: en
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_i18n_Translation-en
                  MD5: 8eb5aa19b3c92a975dc78e2165f6688d


Reverse Depends: 
  ubuntu-server,htop
  lubuntu-qt-desktop,htop
  lubuntu-gtk-desktop,htop
  lubuntu-desktop,htop
  util-vserver,htop
  ubuntu-benchmark-tools,htop
  lubuntu-qt-desktop,htop
  lubuntu-gtk-desktop,htop
  lubuntu-desktop,htop
  hollywood,htop
  freedombox-setup,htop
Dependencies: 
2.1.0-3 - libc6 (2 2.15) libncursesw5 (2 6) libtinfo5 (2 6) lsof (0 (null)) strace (0 (null)) 
Provides: 
2.1.0-3 - 
Reverse Provides: 

다음 명령을 사용하여 패키지가 설치되었는지 여부와 해당 패키지가 속한 리포지토리를 확인하려면:

apt-cache policy apache2

다음 출력이 표시되어야 합니다.

apache2:
  Installed: 2.4.29-1ubuntu4.5
  Candidate: 2.4.29-1ubuntu4.5
  Version table:
 *** 2.4.29-1ubuntu4.5 500
        500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.4.29-1ubuntu4.4 500
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
     2.4.29-1ubuntu4 500
        500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages

APT 고급 사용

다음 명령을 사용하여 끊어진 종속성을 확인할 수도 있습니다.

apt-get check

다음 출력이 표시되어야 합니다.

Reading package lists... Done
Building dependency tree       
Reading state information... Done

패키지(여기서는 vsftpd)의 빌드 종속성을 검색하고 설치하려면 다음 명령어를 사용하세요.

apt-get build-dep vsftpd

다음 출력에서 vsftpd 패키지에 필요한 모든 종속성이 표시되어야 합니다.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libcap-dev' instead of 'libcap2-dev'
The following NEW packages will be installed:
  debhelper dh-apparmor dh-apport libcap-dev libpam0g-dev po-debconf
The following packages will be upgraded:
  libpam0g
1 upgraded, 6 newly installed, 0 to remove and 595 not upgraded.
1 not fully installed or removed.
Need to get 1,020 kB of archives.
After this operation, 2,238 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

패키지의 소스 코드를 다운로드하려면 다음 명령을 실행하여 패키지의 압축을 풀고 컴파일하십시오.

apt-get --compile source htop

다음 출력이 표시되어야 합니다.

Reading package lists... Done
NOTICE: 'htop' packaging is maintained in the 'Git' version control system at:
https://salsa.debian.org/debian/htop.git
Please use:
git clone https://salsa.debian.org/debian/htop.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 314 kB of source archives.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main htop 2.1.0-3 (dsc) [1,961 B]
Get:2 http://archive.ubuntu.com/ubuntu bionic/main htop 2.1.0-3 (tar) [303 kB]                                                                        
Get:3 http://archive.ubuntu.com/ubuntu bionic/main htop 2.1.0-3 (diff) [8,824 B]                                                                      
Fetched 314 kB in 35s (8,877 B/s)                                                                                                                     
dpkg-source: info: extracting htop in htop-2.1.0
dpkg-source: info: unpacking htop_2.1.0.orig.tar.gz
dpkg-source: info: unpacking htop_2.1.0-3.debian.tar.xz
dpkg-source: info: applying 601-openvz-new-ctid-vpid.patch
dpkg-source: info: applying fix-small-terminals.patch
dpkg-source: info: applying fix-ldflags.patch
dpkg-source: info: applying fix-isalnum-crash.patch
dpkg-buildpackage: info: source package htop
dpkg-buildpackage: info: source version 2.1.0-3
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Graham Inggs <>
dpkg-buildpackage: info: host architecture amd64

다음 명령으로 APT 버전을 확인하려면:

apt-get -v

산출:

apt 1.6.1 (amd64)
Supported modules:
*Ver: Standard .deb
*Pkg:  Debian dpkg interface (Priority 30)
 Pkg:  Debian APT solver interface (Priority -1000)
 Pkg:  Debian APT planner interface (Priority -1000)
 S.L: 'deb' Debian binary tree
 S.L: 'deb-src' Debian source tree
 Idx: Debian Source Index
 Idx: Debian Package Index
 Idx: Debian Translation Index
 Idx: Debian dpkg status file
 Idx: Debian deb file
 Idx: Debian dsc file
 Idx: Debian control file
 Idx: EDSP scenario file
 Idx: EIPP scenario file

다음 명령을 실행하여 APT에서 사용 가능한 모든 옵션을 나열할 수 있습니다.

apt-get -h

산출:

apt 1.6.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 - Retrieve new lists of packages
  upgrade - Perform an upgrade
  install - Install new packages (pkg is libc6 not libc6.deb)
  remove - Remove packages
  purge - Remove packages and config files
  autoremove - Remove automatically all unused packages
  dist-upgrade - Distribution upgrade, see apt-get(8)
  dselect-upgrade - Follow dselect selections
  build-dep - Configure build-dependencies for source packages
  clean - Erase downloaded archive files
  autoclean - Erase old downloaded archive files
  check - Verify that there are no broken dependencies
  source - Download source archives
  download - Download the binary package into the current directory
  changelog - Download and display the changelog for the given package

See apt-get(8) for more information about the available commands.
Configuration options and syntax is detailed in apt.conf(5).
Information about how to configure sources can be found in sources.list(5).
Package and version choices can be expressed via apt_preferences(5).
Security details are available in apt-secure(8).
                                        This APT has Super Cow Powers.