Print
카테고리: [ Operating System ]
조회수: 2787

1. Shell이란?

 4개의 shell이 있다.

  1.   Bourne shell (/usr/old/bin/sh)
  2.   C shell (/usr/bin/csh)
  3.   Korn shell (/usr/bin/ksh) : C shell의 대화식 특징을 가진 향상된 Bourne shell로 보다 진보된 상태
  4.   POSIX shell (/usr/bin/sh) : Korn shell과 유사.

2. The Command Line

$ command [arg1] [arg2] [arg3] ……[argn]  arg에는 명령의 대상 또는 관련 옵션이 온다.

3. Standard Input and Output

3-1. Standard input

프로그램 입력을 받을 수 있는 파일. 표준 입력은 file descriptor 0와 관련되어 있다. Redirection을 사용하지 않을 때, 표준입력은 키보드가 됨.

3-2. standard output

프로그램 풀력을 보낼 수 있는 파일. 표준 풀력은 file descriptor 1과 관련됨. Redirection 비 사용 시, 표준출력은 터미널이 된다.

3-3. file descriptor

프로그램이 파일을 참조할 수 있도록 커널에 의해 제공되는 정보. 각 file descriptor번호를 가지고 있다.


4. Redirection

$ command [arguments] > filename
$ cat a > b  (file a를 file b로 출력)
$ cat a c > b  

          or

$ cat a > b $ cat c >> b ('>>'는 추가기능)

5. Pipes

$ command_a [arguments] | command_b [arguments]
$ Command_a [arguments] > temp
$ Command_b [arguments] temp
$ rm temp
$ cat file1 file2 | sort
$ cat file1 file2 > file3
$ sort file3
$rm file3
$ cat file1 file2 | sort | tail | grep | ... (각각의 파이프로 둘러싸인 process들을 fileter라 한다)

6. Running a Program in the Background.

6-1. 개요

  1. 모든 작업은 default로 foreground(즉, 터미널 화면상)에서 작업을 하므로, 작업 수행 시 그 작업이 끝나고 나서야(다음 작업을 받을 준비가 된 상태), prompt를 보여준다.
  2. background작업은 화면이 아닌 시스템 내부에서 실행시킨다. 물론 이 경우 foreground 작업은 따로 실행시킬 수 있다.

6-2. 예제1

ftp 수행 중, 다른 사용자가 talk를 걸어오면, ftp를 종료해야만 talk 사용이 가능하다. 이 경우, 

6-3. 예제2

Shell prompt 상태에서 

$ ls –l | sort &  

이 명령어를 입력하면, 이 작업이 바로 background에서 수행 됨.

Background에서는 multiple로 동시 수행이 가능하다. 즉, background작업으로 여러 개를 돌릴 수 있다.


7. Filename Generation

7-1. ‘?’ special character: 특정 한 개의 문자를 대치.

$ ls memo? 

memo1 memo2 등의 파일 출력.

7-2. ‘*’ special character: 모든 문자 대치.

$ ls memo*

memo1, memo2, memories등의 memo다음에 어떤 문자가 몇 개가 붙더라도 출력.

7-3. ‘[ ]’ special character