shell00

최성현·2022년 8월 23일
0

shell00

목록 보기
1/1

Exercise 02 : Oh yeah, mooore...

tar -xf exo2.tar 압축해제
ln 원본파일 만들파일 -> 하드링크
ln -s test0 test6 -> 심볼릭링크

drwx--xr-x 2 XX XX XX Jun 1 20:47 test0
-rwx--xr-- 1 XX XX 4 Jun 1 21:46 test1

chmod xxx -> xxx는 8진수를 10진수로 변형
test0 맨 앞 d는 디렉토리 l은 심볼릭링크 파일 표시
r (read) w (write) x (execute:실행)
3자릿수 씩 끊어서 파일소유자/그룹/그 외 사용자(others)

touch -t 년도월일시간 파일명 시간 변경
vim 파일명으로 파일 안에 문자 넣어서 문자 수 맞춤

Exercise 03 : Connect me!

klist로 티켓 확인
없다면 kinit 입력 후 인트라 비밀번호 입력
다시 klist 확인해서 유효기간 확인
klist > klist.txt 입력하고
klist.txt 파일 생성

Exercise 04 : midLS

touch로 midLS 생성
여러 디렉토리가 있는 상위 디렉토리로 돌아가서

ls -U 옵션 : 정렬(-t) 또는 긴 출력(-l)에 대한 마지막 수정 대신 파일 생성 시간을 사용합니다.
Use time of file creation, instead of last modification for sorting (-t) or long output (-l).

ls -m 옵션 : 콤마로 구분하여 출력한다.
ls -p 옵션 : 디렉토리에 /를 추가한다.

합쳐서 ls -Ulmp 명령어 입력 디렉토리 내 모든 파일 디렉토리 (숨겨지거나 점 1개 점 2개는 제외)를 생성일 순서로 쉼표 분리 디렉토리 뒤에 / 구분

ex04로 들어가서 파일 midLS 를 vim으로 편집해 ls -Utmp 입력 후 esc :wq 로 저장

터미널에서 man ls 실행해서 옵션 검색

Exercise 05 : GiT commit

git log 하면 git commit한 만큼 아래의 bash창이 표시

commit 0a1eddb0b6199553ce4537a0d6e2d4ee44e7d246 (HEAD -> master)
Author: sunghcho tjdgus9773@gmail.com
Date: Wed Aug 24 11:23:01 2022 +0900

ex09

commit 옆 문자는 commit을 하면 git이 commit한 순서를 알려주는 id로 저장하는 hash 값

0a1eddb0b6199553ce4537a0d6e2d4ee44e7d246가 전체적인 id
**

git은 분산 버전 관리 시스템이라 어떤 상황에서도 commit 할 수 있어야 함
commit id를 정수로 할당하고 저장하면 git은 이전에 commit id가 어떤 것인지 서버에서 최신번호 확인이 필요
따라서 commit id를 hash로 사용하면 온,오프라인 어떤 환경에도 commit이 가능

git은 commit 순서를 기억하려고 SHA1 알고리즘으로 만들어진 hash 값을 사용(SHA1로 만들어진 hash 값은 중복이 없는 임의의 문자열)

git log --pretty="%H" -n5

git log 중 --pretty 옵션은 로그 출력을 기본값 이외의 형식으로 변경하고 몇 가지 사전 구축된 옵션 값으로 사용 가능

%H은 Commit hash를 뜻하는 지정어
%h은 약식 commit hash를 뜻하는 지정어
따라서 %H 지정어 사용이 올바름

-n은 마지막 n번째 커밋만을 보여주는 지정어
따라서 마지막 5개 ID가 필요하므로 -n5

git log

Exercise 06 : gitignore

sunghcho@c8r3s7 test % vim git_ignore.sh
git ls-files --others --ignored --exclude-standard

sunghcho@c8r3s7 test % cat git_ignore.sh
git ls-files --others --ignored --exclude-standard

git 사전

git ls-files
-This merges the file listing in the index with the actual working directory list, and shows different combinations of the two.

-인덱스에 있는 파일 목록이 실제 작업 디렉터리 목록과 병합되고 두 개의 다른 조합이 표시됩니다.

-o
--others
Show other (i.e. untracked) files in the output

-출력에 다른(예: 추적되지 않은) 파일 표시

--exclude-standard
Add the standard Git exclusions: .git/info/exclude, .gitignore in each directory, and the user’s global exclusion file.

-표준 Git 제외 항목: .git/info/exclude, .gitignore를 각 디렉터리에 추가하고 사용자의 전역 제외 파일을 추가합니다.

git ls-files --others --ignored --exclude-standard

git에 파일리스트 --추적되지 않는 --무시되는 --ignored와 무조건 붙는 -표준 기준

git에 무시되면서 추적되지 않는 제외된 표준 기준 파일 리스트들

sunghcho@c8r3s7 test % vim .gitignore
.DS_Store
mywork.c~

sunghcho@c8r3s7 test % cat .gitignore
.DS_Store
mywork.c~

sunghcho@c8r3s7 test % touch .DS_Store
sunghcho@c8r3s7 test % touch mywork.c~

sunghcho@c8r3s7 test % bash git_ignore.sh
.DS_Store
mywork.c~

sunghcho@c8r3s7 test % ls -a
. .. .DS_Store .gitignore git_ignore.sh mywork.c~

제출파일은 git_ignore.sh
.DS_Store/mywork.c~/.gitignore은 작동 확인용이므로 삭제**

Exercise 07 : diff

diff a b > sw.diff

diff 명령어는 파일 a 와 파일 b 안에 있는 내용들의 차이점을 비교하고 합쳐 새로운 sw.diff라는 파일을 만듦

patch a < sw.diff

patch 명령어는 파일 sw.diff 안에 있는 내용 중 파일 a와 겹치는 내용을 빼내고 남아 있는 글 만을 파일 a에 적용

파일 a는 patch로 sw.diff의 a 내용이 없어지고 b의 내용으로 바뀜
파일 a 이름을 파일 b로 이름 변경

Exercise 08 : clean

**find [옵션][경로] [표현식]

현재 디렉토리에서 모든 파일 찾기
find . -type f

print : 검색 결과를 출력. 검색 항목은 newline으로 구분. (기본 값)

delete : 검색된 파일 혹은 디렉토리 삭제**

find . -type f ( -name "~" -o -name "##" ) -print -delete

()는 함수로 인식되기 때문에 \를 붙여야 함수 인식을 무시

-o 는 or

-name "file" : "file"이라는 파일 이름

vim clean 해서 find . -type f ( -name "~" -o -name "##" ) -print -delete 입력 후 :wq(저장 종료)

Exercise 09 : Illusions, not tricks, Michael...

file [OPTION][FILE]

file 명령을 사용하면 파일 내용으로부터 파일 종류를 판별할 수 있다.
또한 새로운 파일 형식이 생겨나도 그 파일의 고유한 시그니처를 알면
magic 파일에 엔트리를 추가하여 그 파일을 인식할 수 있도록 되어 있다.

41 string 42 42 file
파일의 처음부터 41바이트 떨어진 위치의 문자열이 "42"와 일치하는지 확인.
→ 일치하면 42 file이라고 표시

file -m ft_magic test

-m 매직파일 : 지정된 매직파일로 대상 파일을 확인

vim ft_magic
41 string 42 42 file
:wq

vim test
123456789
123456789
123456789
123456789
142
:wq

profile
백엔드 개발자로서 성장해 나가는 성현이의 블로그~

0개의 댓글