The Linux Command

둡둡·2022년 12월 8일
0

Learning the Shell

What is “the Shell”

  • Shell : the operating system to perform (mainly bash=ash or tcsh, zsh)
  • Terminal : a program to interact with user and shell
  • Starting a Terminal : mainly keyboard, can use a mouse
  • Console / Terminal / Shell
  • cf) CLI : Command Line Interface
  • Linux has a single tree
  • Q. What is the Single tree?
    - Different storage devices may be different branches of the tree, but there is always just a single tree
  • pwd : print working directory, show the pathways
  • cd : change directory
    • absolute / relative pathnames
    • cd - : previous paths
    • .. : parent of the paths
  • ls: a list of the files and directories
  • cf) 리눅스의 파일 이름은 마침표로 시작하면 숨김파일, 대소문자 구분, 파일 확장자 없음, 공백 안됨

Looking Around

  • ls : a list of the current working directory
    • /.. : 해당 경로의 리스트, 두 개 동시조회 가능
    • -l(long) : 리스트 상세보기
    • -a(all) : 리스트 전체보기
    • -la : 상위요소까지 모두 상세보기
    • -t(time) : 최신순
    • -r(reverse) : 역순
  • cf) Permssion - 첫글자: “-“ 일반파일, “d” 디렉토리 / 3-3-3: 소유자-그룹-모든 유저의 read-write-execution 권한
  • less : view the content of the text files (cf. more)
  • file : classify a file’s contents

A Guided Tour

  • /home, /root
  • /bin, /sbin
  • /dev, /media
  • /etc, /tmp, /usr 등

Manipulating Files

  • Wildcards : *, ?, [characters], [!char]
  • cp : copy files and directories
    • cp file1 file2(이름으로 복사) / dir(위 경로로 복사)
    • -i : 확인
    • -R : 디렉토리 복사 -> 없으면 생성, 있으면 폴더 안에 생성
  • mv : move or rename, 없으면 이름 바꾸기 있으면 덮어쓰기
    • -i : 덮어쓰기 전에 확인
    • -u : update 최신 버전으로
  • rm : remove(delete)
    • -i : 삭제하기 전에 확인
    • -r : 디렉토리 전체 삭제
  • mkdir : create directories
    • -p : 상위 경로가 없으면 함께 생성

Working with Commands

  • 4 kinds of commands
    • executable program
    • has it itself
    • a shell function
    • an alias
  • Identifying
    • type : the command to examine other command, 커맨드 형식 조회
    • which : to determine the exact location of a given, 커맨드 위치 조회
  • Documentation
    • help : 간략한 매뉴얼 정보
    • —help : 실제 사용법, 옵션 조회*
    • man: 매뉴얼 전용 페이지로 이동하여 정보 조회*

I/O Redirection

  • output
    • “>” : rewrite, no results on the display
    • “>>” : append, new results to the file
  • input
    • “<“ : the results on the display
  • Pipelines “|” : to connect multiple commands
  • filters : sort, uniq, grep, fmt, pr, head, tail, tr, sed, awk
    • grep : find a data that contain a specified pattern of characters
    • sed : stream editor
    • awk : a constructing filters designed by programming language

Expansion

  • echo
  • “*” : wildcards
  • “~” : the home directory of the named user
  • $((…)) : Arithmetic(calculator)
  • {…} : repeat on the content - like for문
  • $parameter
  • “” : 입력문자 그대로 인식, $커맨드 가능
  • ‘’ : $커맨드 불가
  • “\” 이스케이프 : 명령어가 아닌 문자 그대로 사용할때 ($10.0 -> $10.0)
  • \n, \t, \a, \, \f

Permissions

  • “-“ / “d” : 파일/폴더
  • rwx : Read-Write-Execute(Owner-group-others)
    • rwx 7, rw- 6, r-x 5, r-- 4, 0
    • 주로 755, 644 많이 사용
    • (EX) chmod 755 test.txt
  • chmod : modify file access rights
  • su : temporarily become the superuser
  • sudo : temporarily become the superuser
    • Q. What is the differents of su and sudo?
    • su는 root 계정으로 전환(login)
    • sudo는 root 권한만 가져옴(일반 유저인 상태로)
  • chown : change file ownership
  • chgrp : change a file’s group ownership

Job Control

  • ps : the list of processes running on the system
  • kill : send a signal to quit
  • jobs : show of listing your own processes
  • bg(background), fg(foreground)

"LinuxCommand.org", 2000-2022, https://linuxcommand.org/index.php

profile
괴발개발라이프

0개의 댓글