Ubuntu 또는 Debian 패키지를 관리하기 위해 Sysadmin으로 알고 있는 20 apt 명령

APT 또는 고급 패키지 도구는 Debian/Ubuntu 기반 배포판에서 패키지 관리를 위한 명령줄 유틸리티입니다.

apt-get과 함께 사용 가능한 패키지 관리자 중 하나이지만 다른 패키지와 마찬가지로 소스 코드에서 빌드하지 않고도 다른 패키지를 설치, 수정 또는 제거할 수 있습니다. 다음 섹션에서 다룰 패키지 관리와 관련된 훨씬 더 많은 작업을 수행할 수 있습니다.

apt 명령을 사용하는 일반적인 구문은 다음과 같습니다.

$ apt [COMMAND] [PACKAGE]

apt와 함께 sudo를 사용하는 것을 잊지 마십시오. 많은 하위 명령에 시스템 수준 변경 권한이 필요합니다.

여기에서는 apt와 함께 사용할 수 있는 다양한 하위 명령과 그 사용법을 다룰 것입니다.

패키지 데이터베이스 업데이트

apt는 Debian/Ubuntu 시스템에 설치할 수 있는 모든 사용 가능한 패키지 데이터베이스가 있는 패키지 저장소가 필요합니다. apt는 패키지, 해당 버전, 아키텍처 및 원격 위치에 대한 세부 정보를 알아야 하므로 패키지 설치를 시작하기 전에 이 리포지토리 데이터베이스를 업데이트해야 합니다.

리포지토리 데이터베이스 업데이트는 쉽고 다음과 같이 수행할 수 있습니다.

$ sudo apt update

예시:

[email protected]:~$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 http://azure.archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://azure.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:5 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1086 kB]
Get:6 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [841 kB]
Fetched 2255 kB in 1s (2677 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
14 packages can be upgraded. Run 'apt list --upgradable' to see them.
[email protected]:~$

설치된 패키지 업그레이드

시스템에 설치된 패키지는 다음을 사용하여 사용 가능한 최신 버전으로 업그레이드할 수 있습니다.

$ sudo apt upgrade

업그레이드 명령을 사용하면 종속성을 충족하기 위해 필요한 경우 패키지가 설치되지만 기존 패키지는 제거되지 않습니다. 패키지 업그레이드 시 설치된 패키지를 제거해야 하는 경우 이 패키지에 대한 업그레이드는 수행되지 않습니다.

예시:

[email protected]:~$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 http://azure.archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://azure.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:5 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1086 kB]
Get:6 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [841 kB]
Fetched 2255 kB in 1s (2677 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
14 packages can be upgraded. Run 'apt list --upgradable' to see them.
[email protected]:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  apt apt-utils libapt-pkg6.0 libpython3.8 libpython3.8-minimal libpython3.8-stdlib libuv1 linux-base linux-base-sgx open-vm-tools python3-distupgrade python3.8
  python3.8-minimal ubuntu-release-upgrader-core
14 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 9485 kB of archives.
After this operation, 603 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libapt-pkg6.0 amd64 2.0.6 [835 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 apt amd64 2.0.6 [1296 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 apt-utils amd64 2.0.6 [216 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8 amd64 3.8.10-0ubuntu1~20.04 [1625 kB]
Get:5 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8 amd64 3.8.10-0ubuntu1~20.04 [387 kB]
Get:6 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-stdlib amd64 3.8.10-0ubuntu1~20.04 [1675 kB]
Get:7 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8-minimal amd64 3.8.10-0ubuntu1~20.04 [1898 kB]
Get:8 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-minimal amd64 3.8.10-0ubuntu1~20.04 [717 kB]
Get:9 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libuv1 amd64 1.34.2-1ubuntu1.3 [80.8 kB]
Get:10 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 ubuntu-release-upgrader-core all 1:20.04.35 [23.9 kB]
Get:11 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-distupgrade all 1:20.04.35 [104 kB]
Get:12 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-base all 4.5ubuntu3.6 [17.8 kB]
Get:13 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-base-sgx all 4.5ubuntu3.6 [4660 B]
Get:14 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 open-vm-tools amd64 2:11.2.5-2ubuntu1~ubuntu20.04.1 [604 kB]
Fetched 9485 kB in 0s (54.4 MB/s)
Preconfiguring packages ...
(Reading database ... 59511 files and directories currently installed.)
Preparing to unpack .../libapt-pkg6.0_2.0.6_amd64.deb ...
Unpacking libapt-pkg6.0:amd64 (2.0.6) over (2.0.5) ...
Setting up libapt-pkg6.0:amd64 (2.0.6) ...
(Reading database ... 59511 files and directories currently installed.)
Preparing to unpack .../archives/apt_2.0.6_amd64.deb ...
Unpacking apt (2.0.6) over (2.0.5) ...
Setting up apt (2.0.6) ...
(Reading database ... 59511 files and directories currently installed.)
Preparing to unpack .../00-apt-utils_2.0.6_amd64.deb ...
Unpacking apt-utils (2.0.6) over (2.0.5) ...
Preparing to unpack .../01-libpython3.8_3.8.10-0ubuntu1~20.04_amd64.deb ...
Unpacking libpython3.8:amd64 (3.8.10-0ubuntu1~20.04) over (3.8.5-1~20.04.3) ...
Preparing to unpack .../02-python3.8_3.8.10-0ubuntu1~20.04_amd64.deb ...
Unpacking python3.8 (3.8.10-0ubuntu1~20.04) over (3.8.5-1~20.04.3) ...
Preparing to unpack .../03-libpython3.8-stdlib_3.8.10-0ubuntu1~20.04_amd64.deb ...
Unpacking libpython3.8-stdlib:amd64 (3.8.10-0ubuntu1~20.04) over (3.8.5-1~20.04.3) ...
Preparing to unpack .../04-python3.8-minimal_3.8.10-0ubuntu1~20.04_amd64.deb ...
Unpacking python3.8-minimal (3.8.10-0ubuntu1~20.04) over (3.8.5-1~20.04.3) ...
Preparing to unpack .../05-libpython3.8-minimal_3.8.10-0ubuntu1~20.04_amd64.deb ...
Unpacking libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04) over (3.8.5-1~20.04.3) ...
Preparing to unpack .../06-libuv1_1.34.2-1ubuntu1.3_amd64.deb ...
Unpacking libuv1:amd64 (1.34.2-1ubuntu1.3) over (1.34.2-1ubuntu1.1) ...
Preparing to unpack .../07-ubuntu-release-upgrader-core_1%3a20.04.35_all.deb ...
Unpacking ubuntu-release-upgrader-core (1:20.04.35) over (1:20.04.33) ...
Preparing to unpack .../08-python3-distupgrade_1%3a20.04.35_all.deb ...
Unpacking python3-distupgrade (1:20.04.35) over (1:20.04.33) ...
Preparing to unpack .../09-linux-base_4.5ubuntu3.6_all.deb ...
Unpacking linux-base (4.5ubuntu3.6) over (4.5ubuntu3.1) ...
Preparing to unpack .../10-linux-base-sgx_4.5ubuntu3.6_all.deb ...
Unpacking linux-base-sgx (4.5ubuntu3.6) over (4.5ubuntu3.1) ...
Preparing to unpack .../11-open-vm-tools_2%3a11.2.5-2ubuntu1~ubuntu20.04.1_amd64.deb ...
Unpacking open-vm-tools (2:11.2.5-2ubuntu1~ubuntu20.04.1) over (2:11.0.5-4) ...
Setting up libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04) ...
Setting up apt-utils (2.0.6) ...
Setting up linux-base (4.5ubuntu3.6) ...
Setting up python3-distupgrade (1:20.04.35) ...
Setting up libuv1:amd64 (1.34.2-1ubuntu1.3) ...
Setting up linux-base-sgx (4.5ubuntu3.6) ...
Setting up ubuntu-release-upgrader-core (1:20.04.35) ...
Setting up python3.8-minimal (3.8.10-0ubuntu1~20.04) ...
Setting up open-vm-tools (2:11.2.5-2ubuntu1~ubuntu20.04.1) ...
Installing new version of config file /etc/vmware-tools/tools.conf.example ...
Installing new version of config file /etc/vmware-tools/vgauth.conf ...
Setting up libpython3.8-stdlib:amd64 (3.8.10-0ubuntu1~20.04) ...
Setting up python3.8 (3.8.10-0ubuntu1~20.04) ...
Setting up libpython3.8:amd64 (3.8.10-0ubuntu1~20.04) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for systemd (245.4-4ubuntu3.7) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
[email protected]:~$

업그레이드 중 문제를 방지하고 리포지토리에서 사용 가능한 최신 패키지를 가져오려면 패키지를 업그레이드하기 전에 sudo apt update를 실행했는지 확인하십시오. 원하는 경우 다음과 같이 한 줄에서 이러한 명령을 실행할 수 있습니다.

$ sudo apt update && sudo apt upgrade -y

전체 업그레이드 패키지

apt는 전체 업그레이드 명령도 제공합니다. 시스템 전체를 업그레이드하는 데 필요한 경우 현재 설치된 패키지를 제거하므로 업그레이드 명령과 다릅니다. 따라서 이 명령에 주의하고 가능하면 대신 업그레이드 명령을 사용하십시오.

$ sudo apt full-upgrade

단일 패키지 설치

아래 구문을 사용하여 apt로 새 패키지를 설치할 수 있습니다.

$ sudo apt install [package-name]

예시:

[email protected]:~$ sudo apt install unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  zip
The following NEW packages will be installed:
  unzip
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 169 kB of archives.
After this operation, 593 kB of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 unzip amd64 6.0-25ubuntu1 [169 kB]
Fetched 169 kB in 0s (4040 kB/s)
Selecting previously unselected package unzip.
(Reading database ... 59511 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-25ubuntu1_amd64.deb ...
Unpacking unzip (6.0-25ubuntu1) ...
Setting up unzip (6.0-25ubuntu1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
[email protected]:~$

여러 패키지 설치

apt를 사용하여 시스템에 여러 패키지를 설치할 수 있습니다. 이전 예제와 유사한 구문을 따릅니다.

$ sudo apt install [package-name-1] [package-name-2] ... [package-name-n]

예시:

[email protected]:~$ sudo apt install zip unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  unzip zip
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 336 kB of archives.
After this operation, 1231 kB of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 unzip amd64 6.0-25ubuntu1 [169 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 zip amd64 3.0-11build1 [167 kB]
Fetched 336 kB in 0s (7749 kB/s)
Selecting previously unselected package unzip.
(Reading database ... 59527 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-25ubuntu1_amd64.deb ...
Unpacking unzip (6.0-25ubuntu1) ...
Selecting previously unselected package zip.
Preparing to unpack .../zip_3.0-11build1_amd64.deb ...
Unpacking zip (3.0-11build1) ...
Setting up unzip (6.0-25ubuntu1) ...
Setting up zip (3.0-11build1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
[email protected]:~$

지정된 패키지 중 하나가 이미 시스템에 설치되어 있으면 apt는 저장소에서 업데이트를 찾고 사용 가능한 경우 패키지를 업그레이드하거나 설치된 버전을 그대로 유지합니다.

  앱 화면에서 Samsung Discover 옵션을 비활성화하는 방법

특정 버전 설치

특히 엔터프라이즈 시스템에서 특정 버전의 패키지를 설치해야 하는 경우가 많습니다. apt를 사용하면 다음을 사용하여 저장소에서 사용할 수 있다고 가정하고 패키지의 지정된 버전을 설치할 수 있습니다.

$ sudo apt install [package-name]=[version]

예시:

[email protected]:~$ sudo apt install unzip=6.0-25ubuntu1
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  unzip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 169 kB of archives.
After this operation, 593 kB of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 unzip amd64 6.0-25ubuntu1 [169 kB]
Fetched 169 kB in 0s (2767 kB/s)
Selecting previously unselected package unzip.
(Reading database ... 59541 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-25ubuntu1_amd64.deb ...
Unpacking unzip (6.0-25ubuntu1) ...
Setting up unzip (6.0-25ubuntu1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
[email protected]:~$

패키지 제거

패키지 설치와 마찬가지로 apt는 아래 명령을 사용하여 시스템에서 패키지를 제거하는 데 사용할 수 있습니다.

$ sudo apt remove [package-name]

예시:

[email protected]:~$ sudo apt remove unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  unzip
0 upgraded, 0 newly installed, 1 to remove and 14 not upgraded.
After this operation, 593 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 59529 files and directories currently installed.)
Removing unzip (6.0-25ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
[email protected]:~$

패키지 제거

패키지 제거와 마찬가지로 패키지 제거도 동일한 작업을 수행하지만 remove 명령 apt를 사용하면 패키지의 바이너리만 제거하고 구성 파일은 그대로 둡니다. 반면에 purge 명령은 바이너리 및 구성 파일을 포함하여 패키지와 관련된 모든 것이 시스템에서 제거되도록 합니다. 구성 파일을 그대로 두면 응용 프로그램을 다시 설치하려는 경우 동일한 구성 파일을 다시 재사용할 수 있습니다.

  가스 요금 없이 무료로 NFT를 만드는 방법

패키지를 제거하려면 다음을 사용하십시오.

$ sudo apt purge [package-name]

예시:

[email protected]:~$ sudo apt purge unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  unzip*
0 upgraded, 0 newly installed, 1 to remove and 14 not upgraded.
After this operation, 593 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 59529 files and directories currently installed.)
Removing unzip (6.0-25ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
(Reading database ... 59511 files and directories currently installed.)
Purging configuration files for unzip (6.0-25ubuntu1) ...
[email protected]:~$

패키지 검색

apt는 패키지를 설치하고 제거하는 유틸리티 역할만 할 수 있는 것이 아닙니다. 다음과 같이 검색 명령을 사용하여 리포지토리에서 필요한 패키지를 검색할 수도 있습니다.

$ apt search [search-text]

예시:

[email protected]:~$ apt search netstat
Sorting... Done
Full Text Search... Done
bwm-ng/focal 0.6.2-1 amd64
  small and simple console-based bandwidth monitor

gnome-nettool/focal 3.8.1-3 amd64
  network information tool for GNOME

golang-github-aelsabbahy-gonetstat-dev/focal 0.0~git20160428.0.edf89f7-3 all
  Netstat implementation in Go

golang-github-mwitkow-go-conntrack-dev/focal 0.0~git20190716.2f06839-1 all
  Go middleware for net.Conn tracking

libparse-netstat-perl/focal 0.14-1 all
  module to parse the output of the "netstat" command

net-tools/focal 1.60+git20180626.aebd88e-1ubuntu1 amd64
  NET-3 networking toolkit

netstat-nat/focal 1.4.10-3build1 amd64
  tool that display NAT connections

nicstat/focal 1.95-1build1 amd64
  print network traffic statistics

qnetstatview/focal 1.5.6-1 amd64
  Shows detailed listings of all TCP and UDP endpoints

unhide/focal 20130526-4 amd64
  Forensic tool to find hidden processes and ports

whichman/focal 2.4-9 amd64
  Fault tolerant search utilities: whichman, ftff, ftwhich

[email protected]:~$

패키지 내용 보기

패키지에 대한 세부 정보를 보려면 패키지가 설치되었는지 또는 설치할지 여부에 관계없이 아래와 같이 show 명령을 사용할 수 있습니다.

$ apt show [package-name]

예시:

[email protected]:~$ apt show firefox
Package: firefox
Version: 90.0+build1-0ubuntu0.20.04.1
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Mozilla Team <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 226 MB
Provides: gnome-www-browser, iceweasel, www-browser
Depends: lsb-release, libatk1.0-0 (>= 1.12.4), libc6 (>= 2.30), libcairo-gobject2 (>= 1.10.0), libcairo2 (>= 1.10.0), libdbus-1-3 (>= 1.9.14), libdbus-glib-1-2 (>= 0.78), libfontconfig1 (>= 2.12.6), libfreetype6 (>= 2.10.1), libgcc-s1 (>= 3.3), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.42), libgtk-3-0 (>= 3.14), libharfbuzz0b (>= 0.6.0), libpango-1.0-0 (>= 1.14.0), libpangocairo-1.0-0 (>= 1.14.0), libpangoft2-1.0-0 (>= 1.14.0), libstdc++6 (>= 9), libx11-6, libx11-xcb1 (>= 2:1.6.9), libxcb-shm0, libxcb1, libxcomposite1 (>= 1:0.4.5), libxcursor1 (>> 1.1.2), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxi6, libxrender1, libxt6
Recommends: xul-ext-ubufox, libcanberra0, libdbusmenu-glib4, libdbusmenu-gtk3-4
Suggests: fonts-lyx
Replaces: kubuntu-firefox-installer
Task: ubuntu-desktop-minimal, ubuntu-desktop, kubuntu-desktop, kubuntu-full, xubuntu-desktop, lubuntu-desktop, ubuntustudio-desktop, ubuntukylin-desktop, ubuntu-mate-core, ubuntu-mate-desktop, ubuntu-budgie-desktop
Xul-Appid: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
Download-Size: 57.0 MB
APT-Sources: http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Description: Safe and easy web browser from Mozilla
 Firefox delivers safe, easy web browsing. A familiar user interface,
 enhanced security features including protection from online identity theft,
 and integrated search let you get the most out of the web.

N: There is 1 additional record. Please use the '-a' switch to see it
[email protected]:~$

설치된 패키지 나열

다양한 목적으로 시스템에 설치된 패키지를 나열해야 하는 경우가 종종 있습니다. apt를 사용하면 다음과 같이 간단히 설치된 패키지 목록을 얻을 수 있습니다.

$ apt list --installed

모든 패키지 나열

시스템에서 사용할 수 있는 모든 패키지를 나열하려면 다음과 같이 –all-versions 키워드와 함께 list 명령을 사용하십시오.

$ apt list --all-versions

업그레이드 가능한 패키지 나열

중요한 보안 허점을 포함하여 기능이 개선되거나 추가되고 버그 수정이 포함된 새 버전이 계속 릴리스됨에 따라 패키지를 최신 상태로 유지해야 합니다. apt를 사용하면 기사 앞부분에서 제안한 업그레이드 명령으로 Debian/Ubuntu 시스템을 쉽게 패치할 수 있습니다. 시스템에 설치된 패키지에 대해 사용 가능한 모든 업그레이드를 나열하려면 다음을 실행하십시오.

$ apt list --upgradable

예시:

[email protected]:~$ apt list --upgradable
Listing... Done
apt-utils/focal-updates 2.0.6 amd64 [upgradable from: 2.0.5]
apt/focal-updates 2.0.6 amd64 [upgradable from: 2.0.5]
libapt-pkg6.0/focal-updates 2.0.6 amd64 [upgradable from: 2.0.5]
libpython3.8-minimal/focal-updates,focal-security 3.8.10-0ubuntu1~20.04 amd64 [upgradable from: 3.8.5-1~20.04.3]
libpython3.8-stdlib/focal-updates,focal-security 3.8.10-0ubuntu1~20.04 amd64 [upgradable from: 3.8.5-1~20.04.3]
libpython3.8/focal-updates,focal-security 3.8.10-0ubuntu1~20.04 amd64 [upgradable from: 3.8.5-1~20.04.3]
libuv1/focal-updates,focal-security 1.34.2-1ubuntu1.3 amd64 [upgradable from: 1.34.2-1ubuntu1.1]
linux-base-sgx/focal-updates 4.5ubuntu3.6 all [upgradable from: 4.5ubuntu3.1]
linux-base/focal-updates 4.5ubuntu3.6 all [upgradable from: 4.5ubuntu3.1]
open-vm-tools/focal-updates 2:11.2.5-2ubuntu1~ubuntu20.04.1 amd64 [upgradable from: 2:11.0.5-4]
python3-distupgrade/focal-updates 1:20.04.35 all [upgradable from: 1:20.04.33]
python3.8-minimal/focal-updates,focal-security 3.8.10-0ubuntu1~20.04 amd64 [upgradable from: 3.8.5-1~20.04.3]
python3.8/focal-updates,focal-security 3.8.10-0ubuntu1~20.04 amd64 [upgradable from: 3.8.5-1~20.04.3]
ubuntu-release-upgrader-core/focal-updates 1:20.04.35 all [upgradable from: 1:20.04.33]
[email protected]:~$

미사용 패키지 정리

정상적인 사용 시 시스템에 더 이상 필요하지 않은 패키지가 설치되어 있는 경우가 있습니다. 종속성이 시스템에 남아 있지만 나중에 이미 제거된 다른 패키지의 종속성의 일부로 이러한 패키지가 설치되었기 때문에 발생할 수 있습니다. 이러한 패키지를 정리하고 일부 디스크 공간을 확보하려면 다음을 사용할 수 있습니다.

$ sudo apt autoremove

예시:

[email protected]:~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
[email protected]:~$

내 시스템에는 남은 패키지가 없었으므로 출력에 변경 사항이 보고되지 않았습니다.

  공용 USB 포트를 피해야 하는 이유

패키지 종속성 확인

패키지에는 패키지가 올바르게 작동하기 위해 시스템에 설치해야 하는 하나 이상의 종속성이 있을 수 있습니다. apt는 필수 종속성이 패키지 설치의 일부로 설치되도록 합니다. 패키지의 종속성을 확인하려면 다음을 사용하십시오.

$ apt depends [package-name]

예시:

[email protected]:~$ apt depends zip
zip
  Depends: libbz2-1.0
  Depends: libc6 (>= 2.14)
  Recommends: unzip
[email protected]:~$

패키지 재설치

패키지가 손상되거나 모든 패키지 파일의 순서가 올바른지 확인하기 위해 패키지를 다시 설치해야 할 수 있습니다. 먼저 제거하지 않고 패키지를 다시 설치하려면 다음을 사용할 수 있습니다.

$ sudo apt reinstall [package-name]

예시:

[email protected]:~$ sudo apt reinstall unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 169 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 unzip amd64 6.0-25ubuntu1 [169 kB]
Fetched 169 kB in 0s (5695 kB/s)
(Reading database ... 59559 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-25ubuntu1_amd64.deb ...
Unpacking unzip (6.0-25ubuntu1) over (6.0-25ubuntu1) ...
Setting up unzip (6.0-25ubuntu1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
[email protected]:~$

패키지 다운로드

패키지 파일은 설치하지 않고 로컬 파일 시스템에 다운로드할 수 있습니다. apt로 패키지를 다운로드하려면 다음을 사용하십시오.

$ apt download [package-name]

예시:

[email protected]:~$ apt download unzip
Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 unzip amd64 6.0-25ubuntu1 [169 kB]
Fetched 169 kB in 0s (1405 kB/s)
[email protected]:~$

[email protected]:~$ ls -l unzip_6.0-25ubuntu1_amd64.deb
-rw-r--r-- 1 abhisheknair abhisheknair 168956 Aug 16 2019 unzip_6.0-25ubuntu1_amd64.deb
[email protected]:~$

패키지 변경 내역 확인

다음을 사용하여 apt가 있는 모든 패키지에 대한 변경 로그를 쉽게 확인할 수 있습니다.

$ apt changelog [package-name]

소스 편집

apt의 edit-sources 명령을 사용하면 sources.list 파일을 편집하는 동시에 온전성 검사를 제공하여 변경 사항이 일관되고 유효한지 확인할 수 있습니다. 이것은 진행 중인 명령이므로 주의해서 사용해야 합니다. 다음과 같이 sources.list를 편집할 수 있습니다.

$ sudo apt edit-sources

APT 도움 받기

apt 명령에 대한 추가 도움말을 보려면 다음을 사용하십시오.

$ apt help

예시:

[email protected]:~$ apt help
apt 2.0.6 (amd64)
Usage: apt [options] command

apt is a commandline package manager and provides commands for
searching and managing as well as querying information about packages.
It provides the same functionality as the specialized APT tools,
like apt-get and apt-cache, but enables options more suitable for
interactive use by default.

Most used commands:
  list - list packages based on package names
  search - search in package descriptions
  show - show package details
  install - install packages
  reinstall - reinstall packages
  remove - remove packages
  autoremove - Remove automatically all unused packages
  update - update list of available packages
  upgrade - upgrade the system by installing/upgrading packages
  full-upgrade - upgrade the system by removing/installing/upgrading packages
  edit-sources - edit the source information file
  satisfy - satisfy dependency strings

See apt(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.
[email protected]:~$

요약

apt 도구는 Debian/Ubuntu 기반 시스템을 위한 편리하고 강력한 CLI 기반 패키지 관리 유틸리티입니다. 시스템 관리자의 일반적인 일상 업무에는 시스템에서 패키지를 관리하고 apt 및 일반적인 사용 명령을 알고 있으면 이 작업을 쉽게 수행할 수 있습니다.

apt에 대한 추가 도움말은 매뉴얼 페이지를 참조하십시오.

$ man apt