wget 사용

  • wget : url을 통해 파일 다운로드
  • wget url
  • 파일 이름 변경 : mv 원본파일명 변경할파일명.확장자
  • wget -O 원본파일명 변경할파일명.확장자 url



git 사용

  • sudo apt-get install git
  • git clone url 다운받을 디렉토리 명
    • git clone https://github.com/facebook/react.git react_src

에러발생

git_error

sudo killall apt apt-get

만일 진행중인 프로세스가 없다라고 뜬다면 디렉토리를 하나씩 삭제해야한다.

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*

sudo dpkg --configure -a
sudo apt update

CLI

  • semicolon
    • mkdir why
    • cd why
    • 두 명령어를 한번에 하려면? mkdir why;cdwhy
  • pipeline
    • 어떤 명령어(프로그램, 프로세스)의 실행결과를 다른 명령어(프로그램, 프로세스)의 입력으로 준다.
    • grep : 찾고자 하는 단어가 속한 행을 찾는 명령어
      • grep 찾을 단어 찾을파일.확장자
    • 사용설명서에서 sort단어를 찾고 자 할 때 : 파이프이용( | )
      • ls --help | grep sort
      • ls --help | grep sort | grep file
    • 현재 실행중인 프로그램 리스트 중 apache만을 확인하고 자할 때
      • ps aux | grep apache



IO Redirection

  • I : Input
  • O : Output
  • Redirection : 방향을 바꾼다.
    • 출력되는 결과를 방향을 돌려 저장하는 것을 뜻한다.
  • ls -l의 결과를 result.txt를 만들어 저장하고자 할 때
    • ls -l > result.txt

- standard ouput

rename.txt 파일을 삭제한 후 출력결과를 저장해보자.

  • rm rename.txt
  • rm rename.txt > result.txt
    • 오류 발생 : >는 standard output을 향하는 것이지 standard error를 향하는 것이 아니다.
  • rm rename.txt 1> result.txt
    • 오류 발생 : 1이 붙게 되면 standard output(표준출력)이 된다. 로그파일에다가 저장해야 할 듯하다.
  • rm rename.txt 2> error.log
    • 성공 : 2가 붙게 되면 standard error라는 정보를 갖게 된다.
  • rm rename.txt 1> result.txt 2> error.log
    • rename.txt의 결과는 result.txt에 저장하고 만약 오류가 있다면 error.log에 저장한다.



- standard input

  • cat : 사용자가 키보드를 통해 입력한 정보를 받는 명령어
  • cat hello.txt : command-line arguments를 통해서 전달한 입력방식 (대부분 이렇게 쓴다.)
  • cat < hello.txt : hello.txt에 저장되어있는 내용을 입력을 받는다.



Kernel과 Shell

  • shell : 사용자가 입력한 명령어 kernel에 전달. standard input과 standard output, standard error를 통해 사용자와 소통
  • kernel : 사용자가 볼 수 없으며 하드웨어와 프로세스를 잇는 핵심 인터페이스



- bash vs zsh

  • shell의 종류
  • 사용하는 방식에 따라 명령어가 조금씩 다르다.

생활코딩 리눅스강의 통해 학습 중.

'LINUX' 카테고리의 다른 글

Linux 06 : user  (0) 2021.05.20
Linux 05 : cron  (0) 2021.05.20
Linux 04 : background, daemon  (0) 2021.05.20
Linux 03 : shell script  (0) 2021.05.20
Linux 01 : 기본 학습  (0) 2021.05.18

+ Recent posts