본문 바로가기

Computer Science

Bioinformatics Data Skills -CH3. Remedial Unix Shell

[What is Unix?]

The Unix shell is the foundational computing environment for bioinformatics. The shell serves as our interface (1) as an interactive console to inspect data and intermediate results (2) and as the infrastructure for our pipelines and workflows

  • An operating system(OS) just like Windows or Mac.
  • Has been around for a long time (1969)
  • Linux is a Unix-like OS (ubuntu, red hat are linux os)
    • 여기서 주의할점은 Linux는 OS가 아니라 kernel 이라는 점이다.[2]
    • 일반적으로 도구가 없는 커널을 위한 프로젝트(Linux)와 모든 도구가 있지만 커널이 없는 프로젝트(GNU)가 서로 보완하여  된다. 이에따라 GNU 도구를 포함한 GNU/Linux 형태로 Linux를 배포함게 되었고, 사람들은 Linux를 하나의 OS로 생각하게 되었다.
  • Well-suited to working with very large data files
  • Bet you didn’t know – Apple computers use the unix operating system! 

[Structure of Unix]

Hardware : cpu, 메모리, 저장장치 등

Kernel : UNIX OS의 핵심 부분으로서, 파일 시스템, 보안 기능, 메모리 관리 등의 역할을 한다.

Shell : 사용자와 커널간의 소통을 돕는다. 즉 유저의 명령어를 컴퓨터언어로 번역해주는 역할을 한다.

  • bash 보편적으로 사용하는 shell
  • 그 외 csh(C shell), tcsh(tc shell, TENEX C shell, 테넥 셀), ksh(korn shell, 콘 셀), zsh(z shell) 이 존재한다.

Command line  : 디렉토리 및 파일 관리 (cp, rm, mkdir, … ), 네트워크 지원 (ftp, telnet, … ) 등이 존재한다.

 

 

[Unix Philosophy]

  1. Write programs that do one thing and do it well.
    • 한 프로그램이 하나의 작업만을 (잘) 하도록 한다.
  2. Write programs to work together.
    • 다른 프로그램과 협업이 가능하도록 한다.
  3. Write programs to handle text streams, because that is a universal interface.
    • 보편적인 인터페이스인 text stream 을 사용함으로써 보편성을 갖추고 다른 프로그램과 협업이 가능하도록한다.
    • stream은 데이터의 통로이다. 다루는 데이터의 형식에 따라 byte, string, text stream이 존재한다.

[ What is stream? ]

모든 데이터는 바이트로 이뤄져있지만, 스트림에서 바이트를 문자로 인코딩하여 핸들링할 수 있다.

이때 개행문자(\n)를 인식하지 않으면 string stream 이고, 개행 문자(\n)를 인식하면 text stream 이다.

그리고 bioinfomatics의 데이터의 형식이 text 형식이기 때문에, 이 책에서는 연구 환경으로 Unix shell 이 적합하다고 말하고 있다.

 

또한 stream은 한 가지 방향성을 갖고 있으며, 방향성에 따라 여러 stream으로 나눌 수 있다.

키보드로부터 데이터를 입력받아 프로그램으로 전달하는 방향성에는 standard input stream,

프로그램에 처리한 결과물 데이터를 모니터로 송출하는 방향성에는 standard output stream,

프로그램에서 처리과정중에 에러가 발생해 모니터로 송출하는 방향성에는 standard error stream 이 사용된다.

그리고 이 3개의 stream은 모든 프로그램에서 기본적으로 다루는 stream으로서 standard stream 이라 불리운다.

 

 

Reference

[1] Bioinformatics Data Skills - CH3. Remedial Unix Shell

[2] https://unix.stackexchange.com/questions/94402/why-do-people-call-linux-a-kernel-rather-than-an-os