PowerPoint 프레젠테이션

Download Report

Transcript PowerPoint 프레젠테이션

운영체제 – Linux 실습
LAB#9 : 소프트웨어 관리하기
참고교재 : 페도라리눅스 시스템&네트워크(한빛)
목차
 00. 개요
 01. RPM 패키지 설치
 02. yum을 이용한 패키지 설치
 03. 파일 아카이브와 압축
 04. 소프트웨어 컴파일
2
 RPM의 장점과 단점을 설명할 수 있다.
 rpm 명령으로 패키지를 설치하고 업그레이드할 수 있다.
 rpm 명령으로 패키지를 검색하고 상세 정보를 확인할 수 있다.
 yum 명령으로 설치한 패키지와 설치 가능한 패키지, 업데이트할 수 있는
패키지의 목록을 확인할 수 있다.
 yum 명령으로 패키지를 설치하고 업데이트하고 삭제할 수 있다.
 tar 명령으로 아카이브를 생성하고, 내용을 확인하고 풀 수 있다.
 파일을 압축하고 압축을 풀 수 있다.
 gcc로 C 파일을 컴파일할 수 있다.
 makefile을 작성하여 make 명령으로 실행 파일을 만들 수 있다.
3
리눅스 실습 스터디 맵
00 개요
[그림 9-1] 9장의 내용 구성
01 RPM 패키지 설치
 리눅스에서 주로 사용하는 패키지
 RPM(Redhat Package Manager): 레드햇에서 만든 패키지 관리 도구
 .deb: 데비안, 우분투 계열에서 사용하는 패키지
 RPM의 특징
 바이너리 파일로 구성되어 있어 컴파일이 필요 없다.
 패키지의 파일들이 관련 디렉터리로 바로 설치된다.
 한 번에 설치된 패키지의 파일을 일괄적으로 삭제할 수 있다.
 기존에 설치된 패키지를 삭제하지 않고 바로 업그레이드할 수 있다.
 패키지의 설치 상태를 검증할 수 있다.
 패키지에 대한 정보를 제공한다.
 단점: 패키지 의존성에 따라 관련 패키지가 먼저 설치되어 있지 않으면 설치할 수 없다.
 RPM 패키지의 이름 구성
 패키지 이름 : 첫 번째 항목에는 패키지의 이름
 패키지 버전 : 두 번째 항목은 패키지의 버전
 패키지 릴리즈 : 릴리즈는 해당 버전에서 몇 번째 만들어진 것인지를
나타냄. ‘1.fc19’에서 1은 첫 번째 만들어진 패키지임을, fc19는 페도라 19용으로 만들어진 것임을 의미
 아키텍처 : 사용하는 시스템 아키텍처로 x86은 인텔 x86 CPU를, 64는 64비트 운영체제임을 의미
 확장자 : RPM 패키지의 확장자는 .rpm을 사용하여 다른 패키지와 구분
01 RPM 패키지 설치
 rpm 명령
 현재 사용 중인 rpm의 버전 확인
[root@localhost ~]# rpm --version
RPM 버전 - 4.11.1
[root@localhost ~]#
01 RPM 패키지 설치
 RPM 패키지 설치하기
 CD/DVD 장치 연결하기
 페도라 iso 파일 마운트
 Player→Removable Devices→CD/DVD→Settings
 ISO image file이 선택되어 있어야 함
[그림 9-3] CD/DVD장치확인
01 RPM 패키지 설치
 CD/DVD 장치 연결하기
 CD/DVD 마운트
[root@localhost ~]# mount -r -t iso9660 /dev/cdrom /mnt/cdrom
[root@localhost ~]# cd /mnt/cdrom
[root@localhost cdrom]# ls
EFI LiveOS Packages TRANS.TBL images isolinux repodata
[root@localhost cdrom]#
 패키지 위치 찾기: Packages 디렉터리 아래에 패키지 이름의 첫 글자별로 모아서 디렉터리로 구분
[root@localhost
[root@localhost
TRANS.TBL b d
a
c
[root@localhost

cdrom]# cd Packages
Packages]# ls
f h j l n p r t v x z
e g i k m o q s u w y
Packages]#
x 디렉터리에서 xterm 패키지를 찾아보자.
[root@localhost Packages]# cd x
[root@localhost x]# ls xterm*
xterm-293-1.fc19.x86_64.rpm
[root@localhost x]#
01 RPM 패키지 설치
 패키지 설치와 의존성: ivh 옵션
[root@localhost x]# rpm -ivh xterm-293-1.fc19.x86_64.rpm
오류: Failed dependencies:
libXaw.so.7()(64bit) is needed by xterm-293-1.fc19.x86_64
[root@localhost x]#
 xterm 패키지를 설치하려면 libXaw.so.7이 필요하다는 것: libXaw 부터 설치해야함
[root@localhost x]# cd ..
[root@localhost Packages]# cd l
[root@localhost l]# ls libXaw*
libXaw-1.0.11-5.fc19.x86_64.rpm libXaw-devel-1.0.11-5.fc19.x86_64.rpm
[root@localhost l]# rpm -ivh libXaw-1.0.11-5.fc19.x86_64.rpm
준비 중...
################################# [100%]
Updating / installing...
1:libXaw-1.0.11-5.fc19
################################# [100%]
[root@localhost l]#
 다시 xterm 설치
[root@localhost l]# cd ../x
[root@localhost x]# rpm -ivh xterm-293-1.fc19.x86_64.rpm
준비 중...
################################# [100%]
Updating / installing...
1:xterm-293-1.fc19
################################# [100%]
[root@localhost x]#
01 RPM 패키지 설치
 xterm 설치 확인 및 실행
 xterm 명령 확인
[root@localhost x]# whereis xterm
xterm: /bin/xterm /usr/bin/xterm /usr/share/man/man1/xterm.1.gz
[root@localhost x]#
 xterm 실행: X 윈도 환경에서 터미널을 에뮬레이션해주는 프로그램
[그림 9-4] xterm 동작 화면
01 RPM 패키지 설치
 패키지 강제 설치하기
 이미 설치된 패키지를 다시 설치할 경우
[root@localhost x]# rpm -ivh xterm-293-1.fc19.x86_64.rpm
준비 중...
################################# [100%]
xterm-293-1.fc19.x86_64 패키지는 이미 설치되어 있습니다
[root@localhost x]#

강제로 패키지를 설치할 때는 --replacepkgs 옵션을 사용
[root@localhost x]# rpm -ivh --replacepkgs xterm-293-1.fc19.x86_64.rpm
준비 중...
################################# [100%]
Updating / installing...
1:xterm-293-1.fc19
################################# [100%]
[root@localhost x]#
01 RPM 패키지 설치
 RPM 패키지 업그레이드하여 설치하기: -Uvh
[root@localhost x]# cd ../l
[root@localhost l]# rpm -Uvh lynx-2.8.8-0.1.dev15.fc19.x86_64.rpm
준비 중...
################################# [100%]
Updating / installing...
1:lynx-2.8.8-0.1.dev15.fc19
################################# [100%]
[root@localhost l]#
 -U 옵션으로 패키지를 설치할 때 기존에 설치되어 있던 패키지는 업그레이드하여 설치하고 새로운 패키지는 그
대로 설치 -> 따라서 -i 옵션보다는 -U 옵션을 더 많이 사용
01 RPM 패키지 설치
 패키지 정보 검색하기: -q
 전체 패키지 목록 출력하기 : -qa
[root@localhost l]# rpm -qa
kexec-tools-2.0.4-10.fc19.x86_64
libnice-0.1.3-2.fc19.x86_64
pam-1.1.6-12.fc19.x86_64
mtdev-1.1.3-3.fc19.x86_64
gnome-user-docs-3.8.2-1.fc19.noarch
(생략)
01 RPM 패키지 설치
 특정 패키지 설치 여부 확인하기 : -qa | grep
[root@localhost l]# rpm -qa | grep bash
bash-completion-2.1-2.fc19.noarch
bash-4.2.45-1.fc19.x86_64
[root@localhost l]#
 특정 파일을 포함한 패키지 확인하기 : -qf
[root@localhost l]# rpm -qf ls
오류:/mnt/cdrom/Packages/l/ls 파일: 그런 파일이나 디렉터리가 없습니다’
[root@localhost l]#
 왜 오류 발생? -> -f 옵션으로 파일을 지정할 때는 절대 경로 사용
[root@localhost l]# rpm -qf /usr/bin/ls
coreutils-8.21-11.fc19.x86_64
[root@localhost l]#
01 RPM 패키지 설치
 패키지 상세 정보 확인하기 : -qi

패키지 이름 구성에서 첫 번째 항목에 해당하는 부분을 지정
[root@localhost l]# rpm -qi bash
Name
: bash
Version
: 4.2.45
Release
: 1.fc19
Architecture : x86_64
Install Date :
Group
: System Environment/Shells
Size
: 3648696
License
: GPLv3+
Signature
: RSA/SHA256, 2013년 03월 14일 (목) 오후 02시 36분 55초, Key ID
07477e65fb4b18e6
Source RPM
: bash-4.2.45-1.fc19.src.rpm
Build Date
:
Build Host
: buildvm-19.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager
: Fedora Project
Vendor
: Fedora Project
URL
: http://www.gnu.org/software/bash
Summary
: The GNU Bourne Again shell
Description :
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.
[root@localhost l]#
01 RPM 패키지 설치
 패키지 상세 정보 확인하기 : –qif
 -f 옵션을 사용할 경우, 해당 파일이 속한 패키지의 상세 정보가 출력
[root@localhost l]# rpm -qif /usr/bin/ls
Name
: coreutils
Version
: 8.21
Release
: 11.fc19
Architecture : x86_64
Install Date :
Group
: System Environment/Base
Size
: 14559867
License
: GPLv3+
Signature
: RSA/SHA256, 2013년 05월 09일 (목) 오전 12시 56분 21초, Key ID
07477e65fb4b18e6
Source RPM
: coreutils-8.21-11.fc19.src.rpm
(생략)
01 RPM 패키지 설치
 패키지 상세 정보 확인하기 : -qip
 -p 옵션을 사용할 때는 해당 패키지가 위치한 디렉터리를 지정: 패키지 이름만 지정할 경우 오류 발생
[root@localhost l]# rpm -qip bash
오류: bash(을)를 여는데 실패함: 그런 파일이나 디렉터리가 없습니다
[root@localhost l]#
 -p 옵션을 사용할 때는 다음과 같이 패키지 파일이 위치한 디렉터리로 이동하거나 경로를 지정
[root@localhost l]# cd ../c
[root@localhost c]# rpm -qip coreutils-8.21-11.fc19.x86_64.rpm
Name
: coreutils
Version
: 8.21
Release
: 11.fc19
Architecture : x86_64
Install Date : (not installed)
Group
: System Environment/Base
Size
: 14559867
License
: GPLv3+
(생략)
01 RPM 패키지 설치
 패키지가 설치한 파일 목록 확인하기 : -ql
[root@localhost c]# rpm -ql bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
/usr/bin/alias
/usr/bin/bash
/usr/bin/bashbug
(생략)
 패키지의 의존성 확인하기 : -qR
[root@localhost c]# rpm -qR xterm
/bin/sh
/bin/sh
/bin/sh
/bin/sh
libICE.so.6()(64bit)
libX11.so.6()(64bit)
libXaw.so.7()(64bit)
libXft.so.2()(64bit)
libXmu.so.6()(64bit)
libXpm.so.4()(64bit)
(생략)
01 RPM 패키지 설치
 패키지 삭제하기
 앞에서 설치한 xterm 패키지를 삭제
[root@localhost c]# rpm -e xterm
[root@localhost c]# rpm -qa | grep xterm
[root@localhost c]#
02 yum을 이용한 패키지 설치
 yum이란?

‘Yellowdog Updater Modified’의 약자
 Yellowdog이라는 리눅스 배포판에서 제작했던 패키지 관리 도구(yup)와 비슷하다는 데서 이름이 유래

yum은 rpm 기반의 패키지 관리 도구
 yum의 특징
 패키지를 분석하여 패키지의 의존성을 해결하고 원격 자동 업데이트와 설치를 할 수 있다.
 설치 가능한 패키지에 대한 정보가 담긴 저장소(repository)를 가지고 있다.
 저장소의 정보에 의거하여 패키지를 관리한다.
 yum의 기본 형식
02 yum을 이용한 패키지 설치
 패키지 목록 확인하기
 yum list 명령의 출력 형식
패키지명.아키텍쳐 버전-릴리즈 저장소 또는 @설치한 저장소
[root@localhost ~]# yum list | more
Loaded plugins: langpacks, refresh-packagekit
Installed Packages
GConf2.x86_64 3.2.6-6.fc19
@anaconda
LibRaw.x86_64 0.14.8-3.fc19.20120830git98d925
@updates
ModemManager.x86_64 0.6.2.0-1.fc19 @anaconda
NetworkManager.x86_64 1:0.9.8.2-9.git20130709.fc19 @updates
NetworkManager-glib.x86_64 1:0.9.8.2-9.git20130709.fc19 @updates
NetworkManager-l2tp.x86_64 0.9.8-4.fc19
@updates
NetworkManager-openconnect.x86_64 0.9.7.0-2.git20120918.fc19 @anaconda
NetworkManager-openvpn.x86_64 1:0.9.8.2-3.fc19
@updates
(생략)
02 yum을 이용한 패키지 설치
 yum list 명령에서 사용할 수 있는 옵션
02 yum을 이용한 패키지 설치
 yum list available: 설치 가능한 패키지의 목록 검색
[root@localhost ~]# yum list available | more
Loaded plugins: langpacks, refresh-packagekit
Available Packages
0ad.x86_64
0.0.14-1.fc19
0ad-data.noarch
0.0.14-1.fc19
0xFFFF.x86_64
0.3.9-9.fc19
2ping.noarch
2.0-1.fc19
389-admin.i686
1.1.35-1.fc19
389-admin.x86_64
1.1.35-1.fc19
389-admin-console.noarch
1.1.8-5.fc19
389-admin-console-doc.noarch 1.1.8-5.fc19
(생략)
updates
updates
fedora
updates
updates
updates
fedora
fedora
 yum list updates: 업데이트가 가능한 패키지의 목록
[root@localhost ~]# yum list updates
Loaded plugins: langpacks, refresh-packagekit
Updated Packages
yum-langpacks.noarch
0.4.1-3.fc19
[root@localhost ~]#
updates
 yum list installed : 현재 시스템에 설치되어 있는 패키지 목록을 출력
02 yum을 이용한 패키지 설치
 yum check-update: 업데이트 가능한 패키지 목록 확인하기
[root@localhost ~]# yum check-update
Loaded plugins: langpacks, refresh-packagekit
yum-langpacks.noarch
0.4.1-3.fc19
[root@localhost ~]#
updates
02 yum을 이용한 패키지 설치
 패키지 설치하기: yum install 패키지명
 먼저 의존성이 있는 패키지의 존재 여부를 확인
 함께 설치해야 할 패키지 목록 출력
 내려받을 파일의 크기와 실제로 설치되었을 때 필요한 디스크 용량
 설치를 진행할 것인지 확인
① 예: autotrace 패키지 설치 -> 의존성 확인 및 함께 설치할 패키지 목록 출력
[root@localhost ~]# yum install autotrace
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package autotrace.x86_64 0:0.31.1-36.fc19 will be installed
(생략)
Dependencies Resolved
===================================================================================
Package
Arch Version Repository Size
===================================================================================
Installing:
autotrace
x86_64 0.31.1-36.fc19 updates 130 k
Installing for dependencies:
ImageMagick
x86_64 6.7.8.9-5.fc19 fedora 2.1 M
OpenEXR-libs
x86_64 1.7.1-5.fc19 fedora 214 k
ilmbase
x86_64 1.0.3-5.fc19 fedor 99 k
libwmf-lite
x86_64 0.2.8.4-36.fc19 fedora 65 k
02 yum을 이용한 패키지 설치
 패키지 설치하기
② 예: autotrace 패키지 설치 -> 용량 확인 및 설치 여부 문의
Transaction Summary
===================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 2.6 M
Installed size: 9.4 M
Is this ok [y/d/N]:
③ 설치: y로 응답한 경우
Downloading packages:
(1/5): ImageMagick-6.7.8.9-5.fc19.x86_64.rpm
| 2.1 MB 00:01
(2/5): OpenEXR-libs-1.7.1-5.fc19.x86_64.rpm
| 214 kB 00:00
(3/5): ilmbase-1.0.3-5.fc19.x86_64.rpm
| 99 kB 00:00
(생략)
Installed:
autotrace.x86_64 0:0.31.1-36.fc19
Dependency Installed:
ImageMagick.x86_64 0:6.7.8.9-5.fc19
OpenEXR-libs.x86_64 0:1.7.1-5.fc19
ilmbase.x86_64 0:1.0.3-5.fc19
libwmf-lite.x86_64 0:0.2.8.4-36.fc19
Complete!
[root@localhost ~]#
02 yum을 이용한 패키지 설치
 패키지 업데이트하기: yum update 패키지명
[root@localhost ~]# yum update yum-langpacks
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package yum-langpacks.noarch 0:0.4.1-2.fc19 will be updated
---> Package yum-langpacks.noarch 0:0.4.1-3.fc19 will be an update
 Finished Dependency Resolution
Dependencies Resolved
===================================================================================
Package Arch
Version Repository
Size
===================================================================================
Updating:
yum-langpacks noarch 0.4.1-3.fc19 updates 27 k
Transaction Summary
===================================================================================
Upgrade 1 Package
Total download size: 27 k
Is this ok [y/d/N]:
 y로 응답하면 업데이트 진행
02 yum을 이용한 패키지 설치
 패키지 정보 검색하기: yum info 패키지명
 패키지 이름, 패키지 아키텍처, 버전, 릴리즈, 패키지 파일 크기, 저장소, 요약 정보, URL, 라이선스, 설명 출력
[root@localhost ~]# yum info autotrace
Loaded plugins: langpacks, refresh-packagekit
Installed Packages
Name
: autotrace
Arch
: x86_64
Version
: 0.31.1
Release
: 36.fc19
Size
: 339 k
Repo
: installed
From repo : updates
Summary : Utility for converting bitmaps to vector graphics
URL
: http://autotrace.sourceforge.net/
License
: GPLv2+ and LGPLv2+
Description : AutoTrace is a program for converting bitmaps to vector graphics.
(생략)
Available Packages
Name
: autotrace
Arch
: i686
Version
: 0.31.1
Release
: 36.fc19
(생략)
[root@localhost ~]#
02 yum을 이용한 패키지 설치
 패키지 삭제하기: yum remove 패키지명
[root@localhost ~]# yum remove autotrace
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package autotrace.x86_64 0:0.31.1-36.fc19 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================
Package
Arch
Version
Repository
Size
===================================================================================
Removing:
autotrace
x86_64
0.31.1-36.fc19 @updates
339 k
Transaction Summary
===================================================================================
Remove 1 Package
Installed size: 339 k
Is this ok [y/N]:
 패키지를 삭제할 때도 의존성을 확인한 후, 패키지 삭제를 진행할 것인지를 물어봄
03 파일 아카이브와 압축
 파일 아카이브
 파일을 묶어서 하나로 만든 것
 tar(tape archive) 명령은 원래 여러 파일이나 디렉터리를 묶어서 마그네틱테이프와 같은 이동식 저장 장치에 보
관하기 위해 사용하는 명령
 현재는 다른 시스템과 파일을 주고받거나, 백업을 하기 위해 여러 파일이나 디렉터리를 하나의 아카이브 파일
로 생성하거나, 기존 아카이브에서 파일을 추출하기 위해 사용
03 파일 아카이브와 압축
 아카이브 생성하기 : cvf
[user1@localhost linux_ex]$ tar cvf ch2.tar ch2
ch2/
ch2/data1.sl
ch2/data1.ln
ch2/data
ch2/temp/
ch2/temp/data1.cp
ch2/temp/services
ch2/temp/hosts
ch2/temp/text1
ch2/test
ch2/one/
ch2/one/tmp/
ch2/one/tmp/test/
[user1@localhost linux_ex]$ ls
ch2/ ch2.tar ch3/ ch4/ ch5/ ch6/
[user1@localhost linux_ex]$
 tar 명령으로 파일을 묶어서 아카이브 파일을 만들어도 원본 파일은 그대로 있음
03 파일 아카이브와 압축
 아카이브 내용 확인하기 : tvf
[user1@localhost linux_ex]$ tar tvf
drwxrwxr-x
user1/user1
0
lrwxrwxrwx
user1/user1
0
-rw-r--r-user1/user1
158
-rw-r--r-user1/user1
659878
drwxrwxr-x
user1/user1
0
-rw-r--r-user1/user1
158
-rw-r--r-user1/user1
659878
-rw-r--r-user1/user1
158
-rw-r--r-user1/user1
158
-rw-rw-r-user1/user1
0
drwxrwxr-x
user1/user1
0
drwxrwxr-x
user1/user1
0
drwxrwxr-x
user1/user1
0
[user1@localhost linux_ex]$
ch2.tar
2013-03-20
2013-03-19
2013-03-18
2013-03-19
2013-03-19
2013-03-19
2013-03-18
2013-03-18
2013-03-18
2013-01-01
2013-03-18
2013-03-19
2013-03-18
12:55
03:52
20:38
05:45
08:17
05:09
18:56
18:56
18:45
12:00
11:04
08:12
11:04
ch2/
ch2/data1.sl -> data1
ch2/data1.ln
ch2/data
ch2/temp/
ch2/temp/data1.cp
ch2/temp/services
ch2/temp/hosts
ch2/temp/text1
ch2/test
ch2/one/
ch2/one/tmp/
ch2/one/tmp/test/
03 파일 아카이브와 압축
 아카이브 풀기 : xvf
[user1@localhost
[user1@localhost
[user1@localhost
[user1@localhost
ch2/
ch2/data1.sl
ch2/data1.ln
(생략)
[user1@localhost
ch2/ ch2.tar
[user1@localhost
linux_ex]$ mkdir ch9
linux_ex]$ mv ch2.tar ch9
linux_ex]$ cd ch9
ch9]$ tar xvf ch2.tar
ch9]$ ls
ch9]$
03 파일 아카이브와 압축
 아카이브 업데이트하기 : uvf

u 기능은 지정한 파일이 아카이브에 없는 파일이거나, 아카이브에 있는 파일이지만 수정된 파일일 경우 아카
이브의 마지막에 추가 -> ch2/data 파일의 수정시간을 touch 명령으로 수정후 아카이브 업데이트
[user1@localhost ch9]$ tar uvf ch2.tar data
[user1@localhost ch9]$ touch ch2/data
[user1@localhost ch9]$ tar uvf ch2.tar ch2/data
ch2/data
[user1@localhost ch9]$ tar tvf ch2.tar
drwxrwxr-x
user1/user1
0 2013-03-20
lrwxrwxrwx
user1/user1
0 2013-03-19
-rw-r--r-user1/user1
158 2013-03-18
-rw-r--r-user1/user1
659878 2013-03-19
drwxrwxr-x
user1/user1
0 2013-03-19
-rw-r--r-user1/user1
158 2013-03-19
-rw-r--r-user1/user1
659878 2013-03-18
-rw-r--r-user1/user1
158 2013-03-18
-rw-r--r-user1/user1
158 2013-03-18
-rw-rw-r-user1/user1
0 2013-01-01
drwxrwxr-x
user1/user1
0 2013-03-18
drwxrwxr-x
user1/user1
0 2013-03-19
drwxrwxr-x
user1/user1
0 2013-03-18
-rw-r--r-user1/user1
659878 2013-06-10
[user1@localhost ch9]$
12:55
03:52
20:38
05:45
08:17
05:09
18:56
18:56
18:45
12:00
11:04
08:12
11:04
11:29
ch2/
ch2/data1.sl -> data1
ch2/data1.ln
ch2/data
ch2/temp/
ch2/temp/data1.cp
ch2/temp/services
ch2/temp/hosts
ch2/temp/text1
ch2/test
ch2/one/
ch2/one/tmp/
ch2/one/tmp/test/
ch2/data
03 파일 아카이브와 압축
 파일 압축과 아카이브
 아카이브를 생성하면서 동시에 압축 수행
 예: gzip으로 압축
[user1@localhost ch9]$ cp /etc/hosts .
[user1@localhost ch9]$ tar rvf ch2.tar hosts
hosts
[user1@localhost ch9]$ tar tvf ch2.tar
drwxrwxr-x user1/user1
0 2013-03-20
lrwxrwxrwx user1/user1
0 2013-03-19
(생략)
-rw-r--r-- user1/user1
659878 2013-06-10
-rw-r--r-- user1/user1
158 2013-06-10
[user1@localhost ch9]$
12:55 ch2/
03:52 ch2/data1.sl -> data1
11:29 ch2/data
11:35 hosts
03 파일 아카이브와 압축
 파일 압축과 아카이브
 아카이브를 생성하면서 동시에 압축 실행
 예: 아키이브 생성과 동시에 gzip으로 압축 실행: gzip로 압축할 경우 z 옵션을 사용
[user1@localhost ch9]$ tar cvzf ch2.tar.gz ch2
ch2/
ch2/data1.sl
ch2/data1.ln
(생략)
[user1@localhost ch9]$
 예: bzip2로 압축 실행: bzip2로 압축할 경우 j 옵션을 사용
[user1@localhost ch9]$ tar cvjf ch2.tar.bz2 ch2
ch2/
ch2/data1.sl
ch2/data1.ln
(생략)
[user1@localhost ch9]$
03 파일 아카이브와 압축
 파일 압축과 아카이브
 tar 파일로 생성한 것과 압축한 결과의 파일 크기를 비교
[user1@localhost ch9]$ ls -l
합계 2396
drwxrwxr-x. 4 user1 user1
4096
-rw-rw-r--. 1 user1 user1 1996800
-rw-rw-r--. 1 user1 user1
173846
-rw-rw-r--. 1 user1 user1
266708
-rw-r--r--. 1 user1 user1
158
[user1@localhost ch9]$
3월
6월
6월
6월
6월
20
10
10
10
10
12:55
11:35
12:57
12:57
11:35
ch2/
ch2.tar
ch2.tar.bz2
ch2.tar.gz
hosts
 압축한 아카이브 파일의 내용은 tvf로 확인이 가능하며 xvf로 추출 가능
[user1@localhost ch9]$ tar tvf ch2.tar.gz
drwxrwxr-x user1/user1
0 2013-03-20 12:55 ch2/
lrwxrwxrwx user1/user1
0 2013-03-19 03:52 ch2/data1.sl -> data1
-rw-r--r-user1/user1
158 2013-03-18 20:38 ch2/data1.ln
-rw-r--r-user1/user1
659878 2013-06-10 11:29 ch2/data
(생략)
03 파일 아카이브와 압축
 파일 압축하기: gzip/gunzip - .gz 파일
[user1@localhost ch9]$ rm ch2.tar.gz
rm: remove 일반 파일 'ch2.tar.gz'? y
[user1@localhost ch9]$ gzip ch2.tar
[user1@localhost ch9]$ ls
ch2/ ch2.tar.bz2 ch2.tar.gz hosts
[user1@localhost ch9]$
[user1@localhost ch9]$ gzip -l ch2.tar.gz
compressed
uncompressed ratio uncompressed_name
399788
1996800 80.0% ch2.tar
[user1@localhost ch9]$
03 파일 아카이브와 압축

압축 파일의 내용 보기 : zcat
[user1@localhost ch9]$ zcat ch2.tar.gz | more
ch2/
0000000
t4.localdomain4
::1
localhost localhost.localdomain localhost6 localhost6.localdomain6
# $Id: services,v 1.53 2011/06/13 15:00:06 ovasik Exp $
#
# Network services, Internet style
# IANA services version: last updated 2011-06-10
(생략)
03 파일 아카이브와 압축

압축 풀기 : gunzip
[user1@localhost ch9]$ gunzip ch2.tar.gz
[user1@localhost ch9]$ ls
ch2/ ch2.tar ch2.tar.bz2 hosts
[user1@localhost ch9]$
03 파일 아카이브와 압축
 bzip2/bunzip2 : .bz2 파일
[user1@localhost ch9]$ rm ch2.tar.bz2
rm: remove 일반 파일 'ch2.tar.bz2'? y
[user1@localhost ch9]$ bzip2 ch2.tar
[user1@localhost ch9]$ ls
ch2/ ch2.tar.bz2 hosts
[user1@localhost ch9]$
03 파일 아카이브와 압축

압축 파일의 내용 보기 : bzcat

압축 풀기 : bunzip2
[user1@localhost ch9]$ bunzip2 ch2.tar.bz2
[user1@localhost ch9]$ ls
ch2/ ch2.tar hosts
[user1@localhost ch9]$
04 소프트웨어 컴파일
 컴파일러 설치하기
 C 언어로 작성한 프로그램을 컴파일하기 위해서는 C 컴파일러가 필요
 리눅스에서 사용하는 C 컴파일러는 GNU C 컴파일러로 패키지 이름이 gcc
 gcc 설치 여부 확인 -> 설치되어 있지 않음
[user1@localhost ~]$ rpm -qa | grep gcc
libgcc-4.8.1-1.fc19.x86_64
[user1@localhost ~]$
 gcc 설치
[root@localhost ~]# yum install gcc
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.1-1.fc19 will be installed
-->
Processing
Dependency:
cpp
=
4.8.1-1.fc19
for package:
gcc-4.8.1-1.fc19.x86_64
-->
Processing
Dependency:
glibc-devel
>= 2.2.90-12
for
package:
gcc-4.8.1-1.fc19.x86_64
(생략)
Installed:
gcc.x86_64 0:4.8.1-1.fc19
Dependency Installed:
cpp.x86_64 0:4.8.1-1.fc19
glibc-devel.x86_64 0:2.17-18.fc19
glibc-headers.x86_64 0:2.17-18.fc19
kernel-headers.x86_64 0:3.11.2-201.fc19
libmpc.x86_64 0:1.0.1-1.fc19
Complete!
[root@localhost ~]#
04 소프트웨어 컴파일
 간단한 C 프로그램 작성하기
[user1@localhost ch9]$ vi hello.c
#include <stdio.h>
main() {
printf("Hello, World.\n");
}
:wq
 C 프로그램 컴파일하기: 실행파일명은 a.out
[user1@localhost ch9]$ gcc hello.c
[user1@localhost ch9]$ ls
a.out* ch2/ ch2.tar hello.c hosts
[user1@localhost ch9]$
 C 프로그램 실행하기: 경로지정 확인
[user1@localhost ch9]$ ./a.out
Hello, World.
[user1@localhost ch9]$
04 소프트웨어 컴파일
 실행 파일명 변경하기
 gcc로 생성한 기본 실행 파일은 a.out
 사용자가 원하는 이름으로 지정하려면 –o 옵션 사용
[user1@localhost ch9]$ gcc -o hello hello.c
[user1@localhost ch9]$ ./hello
Hello, World.
[user1@localhost ch9]$
04 소프트웨어 컴파일
 make 명령 사용하기
 make 명령은 makefile(또는 Makefile)에 설정된 정보를 읽어서 여러 소스 파일을 컴파일하고 링크하여 최종 실
행 파일을 생성
 소스파일 준비
[user1@localhost ch9]$ vi one.c
#include <stdio.h>
extern int two();
main() {
printf("Go to Module Two--\n");
two();
printf("End of Module One.\n");
}
:wq
 컴파일 하면 오류 발생: two()가 무엇인지 모르겠다는 메시지
[user1@localhost ch9]$ gcc one.c
/tmp/ccBLblUS.o: In function 'main':
one.c:(.text+0x14): undefined reference to 'two'
collect2: error: ld returned 1 exit status
[user1@localhost ch9]$
04 소프트웨어 컴파일
 make 명령 사용하기
 두 번째 파일 생성: two() 함수 정의
[user1@localhost ch9]$ vi two.c
#include <stdio.h>
two() {
printf("In Module Two--\n");
printf("--- This is a Moudule Two.\n");
printf("End of Module Two.\n");
}
:wq
 makefile 작성하기
[user1@localhost ch9]$ vi maekfile
TARGET=one
OBJECTS=one.o two.o
${TARGET} : ${OBJECTS}
gcc -o ${TARGET} ${OBJECTS}
one.o : one.c
gcc -c one.c
two.o : two.c
gcc -c two.c
:wq
04 소프트웨어 컴파일
 make 파일 실행
[user1@localhost ch9]$ make
gcc -c one.c
gcc -c two.c
gcc -o one one.o two.o
[user1@localhost ch9]$ ./one
Go to Module Two-In Module Two---- This is a Moudule Two.
End of Module Two.
End of Module One.
[user1@localhost ch9]$