35
BASIC UNIX COMMANDS AND CONCEPTS PART 2 logue 08 김김김

Basic Unix Commands and Concepts Part 2

Embed Size (px)

DESCRIPTION

Basic Unix Commands and Concepts Part 2. logue 08 김도국. Saving Your Output. Redirection! $ ls / usr /bin > ~/Binaries 기본적으로 덮어쓰기로 설정되어 있다 . $ noclobber =1 위의 명령으로 덮어쓰기를 방지. 명령. 출력을 저장할 파일. Saving Your Output. $ ls /bin >> ~/Binaries 기존 파일에 내용을 추가하는 방법 - PowerPoint PPT Presentation

Citation preview

Page 1: Basic Unix Commands and Concepts Part 2

BASIC UNIX COM-MANDS

AND CONCEPTS PART 2

logue08 김도국

Page 2: Basic Unix Commands and Concepts Part 2

Saving Your Output

Redirection! $ ls /usr/bin > ~/Binaries

기본적으로 덮어쓰기로 설정되어 있다 . $ noclobber=1 위의 명령으로 덮어쓰기를 방지

명령 출력을 저장할 파일

Page 3: Basic Unix Commands and Concepts Part 2

Saving Your Output

$ ls /bin >> ~/Binaries 기존 파일에 내용을 추가하는 방법

리눅스의 출력 스트림에는 표준 출력과 표준 에러가 있음

지금까지의 방법에서는 표준 에러는 리다이렉트하지 않음

Page 4: Basic Unix Commands and Concepts Part 2

Saving Your Output

$ gcc invinitjig.c >& error-msg 표준 출력 , 표준 에러 모두 리다이렉트

$ gcc invinitjig.c 2> error-msg 표준 에러만 리다이렉트

$ gcc invinitjig.c 2>error-msg >/dev/null 표준출력은 버리고 , 표준에러 리다이렉트

Page 5: Basic Unix Commands and Concepts Part 2

Saving Your Output

test.py

Page 6: Basic Unix Commands and Concepts Part 2

Saving Your Output

Page 7: Basic Unix Commands and Concepts Part 2

Saving Your Output

Page 8: Basic Unix Commands and Concepts Part 2

Saving Your Output

Page 9: Basic Unix Commands and Concepts Part 2

Saving Your Output

Page 10: Basic Unix Commands and Concepts Part 2

Saving Your Output

Page 11: Basic Unix Commands and Concepts Part 2

Saving Your Output

Pipe(|)

Page 12: Basic Unix Commands and Concepts Part 2

What Is a Command?

$ ls $ /bin/ls

$ export PATH=$PATH : /usr/sbin

추가하려는 명령의 경로

Page 13: Basic Unix Commands and Concepts Part 2

Background Command

$ fg (%)1 1 번 작업으로 복귀 $ jobs 현재 배경작업의 수를 확인 $ kill %1

Page 14: Basic Unix Commands and Concepts Part 2

Background Command

Page 15: Basic Unix Commands and Concepts Part 2

Background Command

Page 16: Basic Unix Commands and Concepts Part 2

Manual Pages

$ man ls $ man 1 ls

1 : 사용자 명령 2 : 유닉스 시스템 호출 5 : 파일 형식 8 : 시스템 관리 명령

Page 17: Basic Unix Commands and Concepts Part 2

Manual Pages

$ apropos edit

$ export MANPATH=/usr/man:/usr/local/man

Page 18: Basic Unix Commands and Concepts Part 2

File Ownership and Permissions

읽기 권한 : 파일 내용을 볼 수 있다 . 쓰기 권한 : 파일을 변경하거나 지울 수 있다 . 실행 권한 : 파일을 실행할 수 있다 .

디렉토리의 경우 읽기 권한 : 디렉토리의 내용을 볼 수 있다 . 쓰기 권한 : 파일을 추가하거나 지울 수 있다 . 실행 권한 : 파일 정보를 볼 수 있다 .

Page 19: Basic Unix Commands and Concepts Part 2

File Ownership and Permissions

logue 는 읽고 , 쓰고 , 실행할 수 있다 . Sparcs 에 속하는 계정은 읽을 수 있다 . 그 외의 계정은 읽을 수 있다 . 소유자는 logue, 그룹은 sparcs 이다 .

Page 20: Basic Unix Commands and Concepts Part 2

Changing the Ownership

# chown bin sampsoft root 만이 chown 을 실행할 수 있다 .

# chgrp bin sampsoft 파일의 소유자면 chgrp 로 자신이 속한 다른

그룹으로 파일의 그룹 소유권을 변경하는 것이 가능하다 .

Page 21: Basic Unix Commands and Concepts Part 2

Changing the Permission

$ chmod +x header $ chmod –x header

$ chmod u+x header $ chmod ugo+rwx header

Page 22: Basic Unix Commands and Concepts Part 2

Changing the Permission

$ chmod 555 header $ chmod 444 header

$ umask 027

Page 23: Basic Unix Commands and Concepts Part 2

Changing the Permission

setUID- 실행할 때 파일 소유자의 권한을 임의로 가진다 .

$ chmod 4xxx file/directory

Page 24: Basic Unix Commands and Concepts Part 2

Changing the Permission

setGID- 실행할 때 해당 그룹에 포함된 계정은 사용자 권한을 임의로 가진다 .

$ chmod 2xxx file/directory

Page 25: Basic Unix Commands and Concepts Part 2

Changing the Permission

Sticky bit- 삭제에 대한 권한은 root 와 소유자만이 가진다 .

$ chmod 1xxx file/directory

Page 26: Basic Unix Commands and Concepts Part 2

Startup Files

Page 27: Basic Unix Commands and Concepts Part 2

Startup Files

.bashrc 의 예 RS1=‘/u$’ : # 프롬프트에 사용자의 로그인명을

포함한다 . HISTSIZE=50 : 위 화살표로 살펴볼 수 있는

명령을 50 개로 제한 PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11

명령을 찾기 위해 검색하는 모든 디렉토리 stty erase “^H” : 백스페이스 키를 제대로

동작하게 해준다 .

Page 28: Basic Unix Commands and Concepts Part 2

Important Directories

/bin : ls 와 같은 가장 중요한 유닉스 명령이 위치 /usr/bin : 기타 명령어를 포함 /usr/sbin : 시스템 관리를 위한 명령어가 위치 /boot : 부팅 중 사용되는 커널과 기타 파일들 /etc : 네트워킹 , NFS, 메일 등의 하위시스템에서

사용하는 파일들이 위치 /var : 다양한 유틸리티에서 사용하는 로그 파일과

같은 관리용 파일

Page 29: Basic Unix Commands and Concepts Part 2

Daemon Programs

항상 백그라운드에서 실행되는 프로그램 네트워크를 통해 클라이언트의 여러 요청에

서비스하기 위한 서버 프로그램 /etc/inittab, /etc/inetd.conf 파일을 통해 데몬의

실행을 살펴볼 수 있다 .

부팅시 자동실행되는 데몬 단독으로 실행 , 중지할 수 있는 데몬

Page 30: Basic Unix Commands and Concepts Part 2

Daemon Programs

Page 31: Basic Unix Commands and Concepts Part 2

Daemon Programs

단독 데몬의 실행과 중지 , 재시작 # service (daemonname) start | stop | restart

부팅시 자동실행되는 데몬의 관리 # ntsysv : 현재 레벨의 데몬 관리 지정 # ntsysv –level3 : 3 번 레벨의 데몬 관리 지정

Page 32: Basic Unix Commands and Concepts Part 2

Daemon Programs

$ nohap (command) & 해당 명령을 daemon program 처럼

백그라운드에서 지속적으로 동작하게 한다 . 흔한 백그라운드 작업과 다른 점은 로그아웃

시에도 작업이 계속된다는 점이다 .

Page 33: Basic Unix Commands and Concepts Part 2

Processes

자신의 리소스를 지니고 있는 독립된 , 실행 중인 프로그램을 일컫는다 .

$ ps

Page 34: Basic Unix Commands and Concepts Part 2

Processes

$ ps ax | more 실행 중인 모든 프로세스를 살펴볼 수 있다 .

$ kill (process-id)

Page 35: Basic Unix Commands and Concepts Part 2

ReferenceRunning Linux 4th Edition

Google

Thank you for listening!