728x90
리눅스에서 .tar 또는 .tar.gz 파일을 압축 및 압축풀기 할 때마다 헷갈려하다가, 이 기회에 tar commend를 이용한 파일 압축 및 해제 방법을 정리하는 글을 포스팅하겠다.
1. 옵션 정리
-c: Create a new archive (압축 파일 생성)-v: Verbose output to show progress in the terminal (verbose 정보를 터미널에 출력)-f: Specify the filename of the archive (해당 옵션 뒤에 항상 파일 이름을 입)-z: Compress/Decompress with gzip (-zfor gzip,-jfor bzip2) (gzip으로 압축/풀기)-x: Extract the archive (파일 압축 풀기)-C: Change to a specific directory before creating/extracting the archive (특정 경로로 이동)
2. 파일 압축하기 (-c 옵션 사용)
.tar로 압축
tar -cvf archive_name.tar /path/to/directory_or_files
.tar.gz(Gzipped tar)로 압축
tar -czvf archive_name.tar.gz /path/to/directory_or_files
- 특정 파일 경로를 지정하여 압축
tar -czvf archive_name.tar.gz -C /path/to/files .
새 archive를 생성(create, -c)하기 전에 /path/to/files 디렉토리로 이동(Change to the directory, -C) 후, /path/to/files 경로 내에서의 현재 디렉토리(.)의 파일들을 압축
3. 파일 압축풀기 (-x 옵션 사용)
.tar파일 압축풀기
tar -xvf archive_name.tar
.tar.gz파일 압축풀기
tar -xzvf archive_name.tar.gz
- 특정 파일 경로를 지정하여 압축풀기
tar -xzvf archive_name.tar.gz -C /path/to/extract/directory
archive_name.tar.gz파일을 /path/to/extract 디렉토리에 압축 풀기
728x90
'메모 > 코딩' 카테고리의 다른 글
| [링크] PC에 리눅스(우분투 14.04) 설치하기 (0) | 2024.06.28 |
|---|---|
| [코딩] 내가 보려고 만든 이미지 처리 (0) | 2024.06.28 |
| Command 'nvcc' not found 오류 원인 및 해결 (0) | 2024.03.27 |
| VSCode를 이용하여 윈도우와 WSL 리눅스 간 파일 이동하기 (0) | 2024.01.14 |
| Windows WSL 및 Anaconda 3 설치 (0) | 2024.01.13 |
댓글