1. Path: pwd, cd
- pwd (print working dirctory)
- cd (change directory)
cd / : 루트 디렉토리
cd ~ : 홈 디렉토리
cd - : 이전 경로로 이동 후 현재 경로 보여줌
cd .. : 이전 경로
cd : 홈 디렉토리로 이동 (생략시)
2. Dirctoty
- 절대경로 (absolute path)
/를 시작으로 하는 경로
e.g. /usr/localbin
- 상대경로 (relative path)
현재 디렉토리(.)를 시작으로 하는 경로
e.g. work/tmp == ./work/tmp, 즉 ./는 보통 생략이 가능하다
- 디렉토리나 파일 앞에 .이 붙은 경우: 숨겨진 파일/디렉토리
3. file: ls
- ls: list file
- ls [-altriRr] [파일명]
- a: all
- l: long
- t: sort by time
- r: reverse
- file type:
- -: regular file
- d: directory
- l: symbolic link
4. file: UNIX file mode
- 3+9 bit의 UNIX file mode
- 3 bit: SetUID(usr ID), SetGID(group ID), Sticky bit [보안과 관련이 있는 허가 권한]
- 9 bit: owner, group, others의 접근 권환
- 표기 방법
- symbolic mode: 'rwx' symbol로 표기
- Octal mode: bit를 8진수법으로 표기
- r: readable (2^2 = 4)
- w: writable (2^1 = 2)
- x: excutable (2^0 = 1)
5. directory: mkdir, rmdir
- mkdir: make directory
- mkdir [-p] <directory name>
- rmdir: remove directory
- rmdir [-p] <directory name>
- rm -rf로 안의 파일까지 모두 지우는 경우가 많음
6. file: cp, mv, rm
- cp: copy
- mv: move, rename
- rm: remove
7. file: chmod, chown, chgrp
- chmod: change mode
- chmod u+x,g=rx,o= <file>
- chmod 750 <file>
- chown: change owner
- chgrp: change group
8. file
- 파일은 고유의 표시을 가지고 있어 이를 근거로 파일의 종류를 분류 가능 (magic data)
이런 이유로 파일의 확장자는 중요하지 않다.
file <file\>
9. stat
- 파일의 meta data 출력
stat [option] <file>
- mtime: file의 data가 변경된 시간 (modification)
- ctime: file의 meta data가 변경된 시간 (change)
10. touch
- 파일의 메타정보 업데이트
- 파일이 존재하지 않는 경우 빈 파일 생성
touch <file>
11. find
- 유닉스 계열의 중요한 명령어
find directory [expression]
- expression
- -name: 같은 이름 검색
- -size n: 크기 조건으로 검색
- -mtime/mmin n : 변경된 시간 조건 (day/minute)
- -a: and (생략 가능)
- -o: or
- exec : 검색 후 작업 지시
- ㅇㄴㅁ
find .... -exec 명령어 \; or \+
tip
!$: 바로 이전 명령어의 경로
디렉토리 자리에 .이 온다면 현재 디렉토리를 의미함