티스토리 뷰

리눅스

Ubuntu 프로그램 설치 명령 (apt-get)

거북이 개발자 2018. 5. 11. 15:06

Ubuntu에서 프로그램 관리 명령은 dpkg, apt-get 이 있습니다. dpkg의 경우 초창기 명령이며 요즘은 패키지 의존성 문제때문에 거의 사용하지 않는다고 합니다. apt-get은 dpkg의 패키지 의존성 문제를 해결함으로써 Ubuntu의 대표적인 프로그램 관리 명령어 입니다.


 apt-get 명령 설명을 하기전에 우선 apt-get의 동작원리부터 알아보겠습니다. 


[apt-get 동작 원리 (출처: 이것이 우분투 리눅스다 동영상 캡쳐)]


  1. apt-get install 패키지명   명령 프롬프트에 입력.
  2. /etc/apt/sources.list 파일의 URL 주소를 확인.
  3. 확인된 우분투 패키지 저장소로 설치와 관련된 패키지 목록을 요청. 
  4. 설치에 필요한 패키지 파일 요청.
  5. 설치할 패키지 파일을 다운로드해서 설치

⊙ 우분투 패키지 저장소 종류
- main: 우분투에서 공식적으로 지원하는 무료 패키지
- universe: 우분투에서 지원하지 않는 무료 패키지
- restricted: 우분투에서 공식적으로 지원하는 유료 패키지
-  multiverse: 우분투에서 지원하지 않는 유료 패키지

⊙/etc/apt/sources.list 파일

deb http://site.http.org/debian xenial main

deb-src http://site.http.org/debian xenial main


- 이 파일에는 기본적으로 우분투 패키지 저장소 주소가 기록되어 있음.

- 파일 내용 

 deb

 http://site.http.org/debian 

 xenial

 main

- 아카이브 형태: deb/deb-src

- 우분투 저장소 URL

- 우분투 버전 코드명: xenial 은 Ubuntu 16.04를 의미함. 자동으로 업데이트 된 

   패 키지를 설치하기 위해서는 xenial-updates 를 코드명으로 사용하면 됨.

- 저장소 종류: main 은 우분트 지원 무료 패키지 저장소를 의미함.


※ 우분투 미러서버들 확인 URL: https://launchpad.net/ubuntu/+archivemirrors
패키지 설치가 잘 되지 않는 경우 /etc/apt/sources.list 파일에서 우분투 미러 사이트를 변경하여 사용할 수 있습니다. 

/etc/apt/sources.list 파일을 수정한 경우에는 다음 명령을 실행해야 적용이 됩니다. 
#>apt-get update
보다 자세한 내용들은 man apt-get 명령을 이행하시거나 우분투 사이트에서 확인하시면 될 듯 합니다. 

이제 간단한 개념 설명을 했으니 실제 명령을 샘플을 통해 apt-get 명령에 대해서 알아보겠습니다. 
#> apt-get install mysql-server
#> apt-get -y install mysql-server

mysql -server 패키지를 설치합니다. -y 옵션을 사용하면 사용자의 확인을 모두 yes로 간주하고 설치를 진행합니다.

#> apt-get remove mysql-server
#> apt-get purge mysql-server

mysql-server 패키지를 제거합니다. remove의 경우 설정파일은 삭제하지 않지만 purge를 이용하면 설정파일까지 삭제를 합니다.

#> apt-get autoremove mysql-server
#> apt-get autoremove

remove는 해당 패키지만 삭제하지만 autoremove의 경우 mysql-server 설치시에 의존성 때문에 자동으로 설치된 패키지까지 모두 제거합니다.
autoremove만 사용하는 경우 현재 시스템에서 사용하지 않는 패키지를 모두 제거합니다.

#> apt-get clean
#> apt-get autoclean

기본적으로 /var/cache/apt/archives 디렉터리에 다운로드한 파일들을 삭제합니다.

#> apt-get update

/etc/apt/sources.list 기반으로 우분투 패키지 저장소 정보를 갱신합니다.

#> apt-get upgrade

시스템에 설치되어 있는 모든 패키지들을 최신으로 업데이트 합니다. 모든 패키지에 대해서 업그레이드를 실행하기 때문에 많은 시간이 소요되며 최신 버전이라고는 하지만 해당 시스템에서 제대로 동작하지 않을 수 있기 때문에 실제 사용중인 시스템이라면 권장하지 않는 명령이다.


이제 패키지 설치 전후에 패키지 정보를 볼수 있는 apt-cache 명령에 대해서 알아보겠습니다. 
apt-cache 명령은 기본적으로 패키지를 설치하기 전에 패키지에 대한 정보나 의존성 문제를 미리 확인할 수 있도록 해줍니다. 
#> apt-cache show mysql-server
Package: mysql-server
Priority: optional
Section: database
Installed-Size: 180
Maintainer: Ubuntu Developers 
Original-Maintainer: Debian MySQL Maintainers 
Architecture: all
Source: mysql-5.7
Version: 5.7.11-0ubuntu6
Depends: mysql-server-5.7
Filename: pool/main/m/mysql-5.7/mysql-server_5.7.11-0ubuntu6_all.deb
Size: 10128
MD5sum: 7fc525a0e6aa6969855a8080eeb73bf8
SHA1: be3f5f662ade14c52e966e6f17ad274f17cb0236
SHA256: 67b3359a60ed3c215c276956563baec47c9437b72858bc09bc74a101c0cb219c
Description-ko: MySQL 데이터베이스 서버 (최신버전에 의존하는 메타패키지)
 This is an empty package that depends on the current "best" version of
 mysql-server (currently mysql-server-5.7), as determined by the MySQL
 maintainers. Install this package if in doubt about which MySQL version
 you need. That will install the version recommended by the package
 maintainers.
 .
 MySQL은 빠르고, 안정적이며 진정한 의미로 다중 사용자, 다중 쓰레드 SQL 데이터베이스 서버입니다. SQL (Structured
 Query Language)은 세계에서 가장 대중적인 데이터베이스 쿼리 언어입니다. MySQL은 속도, 신뢰성, 그리고 사용의 편의를
 최우선 목표로 하고 있습니다.
Description-md5: b8b44aa3bf1e86bb2834ded6d9d869b5
Homepage: http://dev.mysql.com/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master

mysql-sever 패키지 정보를 확인 할 수 있습니다.

#> apt-cache depends mysql-server
mysql-server
  의존: mysql-server-5.7
#> apt-cache depends mysql-server-5.7
mysql-server-5.7
  미리의존: adduser
  미리의존: debconf
  미리의존: mysql-common
  의존: apparmor
  의존: bsdutils
    bsdutils:i386
  의존: initscripts
    initscripts:i386
  의존: lsb-base
  의존: mysql-client-5.7
  의존: mysql-common
  의존: mysql-server-core-5.7
  의존: passwd
    passwd:i386
  의존: perl
  의존: psmisc
    psmisc:i386
 |의존: debconf
  의존: 
    cdebconf
    debconf
  의존: init-system-helpers
  의존: libc6
  의존: libgcc1
  의존: libstdc++6
  의존: zlib1g
  충돌: 
  충돌: 
  충돌: 
    percona-server-server-5.6
    percona-xtradb-cluster-server-5.6
    mariadb-server-10.0
  망가뜨림: 
  추천: libhtml-template-perl
  제안: 
    bsd-mailx
    mailutils
    s-nail
  제안: tinyca
  대체: 
  대체: 
  대체: 
  대체: 
    percona-server-server-5.6
    percona-xtradb-cluster-server-5.6
    mariadb-server-10.0
    mysql-server-5.7

mysql-server의 의존성 확인할 수 있습니다.

#>apt-cache rdepends mysql-server-5.7

mysql-server-5.7 패키지의 역의존성을 확인할 수 있습니다. 다시말해 mysql-server-5.7 패키지를 의존하고 있는 패키지 목록을 확인할 수 있습니다.

'리눅스' 카테고리의 다른 글

Ubuntu 리눅스 cron 서비스 사용하기  (0) 2018.05.18
리눅스 find 명령 예제  (0) 2018.05.18
리눅스 (Ubuntu) tar 명령 예제  (0) 2018.05.18
파일과 디렉토리의 소유, 허가  (0) 2018.05.11
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함