zip 명령어: 폴더 압축과 unzip 풀기, 압축 옵션

공정위 광고 문구 Ver 3.1
공정위 광고 문구 Ver 3.2(모바일 전용)
테스트 환경RHEL 계열AlmaLinux 9.8root 계정2026-11-05 확인
압축 · 보관 명령어zipunzip위치/usr/bin/zip
폴더 압축과 unzip 풀기

zip 명령어는 리눅스에서 파일과 폴더를 zip 파일 하나로 묶어 압축하고, 압축을 풀 때는 unzip을 함께 사용합니다. AlmaLinux 9 서버에서 웹 사이트 폴더를 zip -r로 압축한 결과 35,825바이트가 4,158바이트로 줄었고, Windows에서 만든 zip 파일의 깨진 파일 이름은 unzip -O로 바로잡았습니다.

아래 출력은 AlmaLinux 9.8 서버의 root 계정으로 작업 폴더 안에서 실행한 결과이고, 시각은 UTC 기준입니다. 압축한 site 폴더와 메모 파일은 시험용으로 만든 예시 파일입니다. Windows에서 만든 zip은 파일 이름을 CP949로 넣은 시험용 파일로 재현했습니다.

1️⃣ zip 명령어 사용법

  • ↪️ 파일 압축과 폴더 압축(-r)

zip 뒤에는 새로 만들 zip 파일 이름을 먼저 적고, 그 뒤에 담을 파일을 나열합니다. 아래는 readme.txt와 memo.txt 두 파일을 notes.zip 하나로 압축하는 명령입니다.

zip notes.zip readme.txt memo.txt
  adding: readme.txt (deflated 92%)
  adding: memo.txt (stored 0%)

줄 끝의 [deflated 92%]는 원래 크기에서 줄어든 비율입니다. 71바이트인 memo.txt 줄의 [stored 0%]는 압축하지 않고 원래 크기 그대로 담았다는 뜻입니다.

폴더를 압축할 때는 -r을 붙입니다. -r 없이 폴더 이름만 적으면 폴더 항목 site/ 하나만 담기고, 안의 파일은 들어가지 않습니다.

zip nodir.zip site
  adding: site/ (stored 0%)

압축할 site 폴더는 아래처럼 하위 폴더 셋과 파일 여섯으로 되어 있습니다.

site/
css/
style.css
js/
app.js
logs/
access.log
index.html
about.html
.htaccess

-r을 붙이면 하위 폴더와 그 안의 파일, 점으로 시작하는 .htaccess까지 열 항목이 모두 담깁니다.

zip -r site.zip site
  adding: site/ (stored 0%)
  adding: site/css/ (stored 0%)
  adding: site/css/style.css (deflated 93%)
  adding: site/js/ (stored 0%)
  adding: site/js/app.js (deflated 87%)
  adding: site/logs/ (stored 0%)
  adding: site/logs/access.log (deflated 94%)
  adding: site/index.html (deflated 91%)
  adding: site/about.html (deflated 87%)
  adding: site/.htaccess (deflated 9%)

압축이 끝난 zip 파일에 무엇이 들었는지는 압축을 풀지 않고 unzip -l로 확인합니다. 담긴 파일 크기의 합은 35,825바이트였고, ls -l로 본 site.zip은 4,158바이트였습니다.

unzip -l site.zip
Archive:  site.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  10-28-2026 22:10   site/
        0  10-28-2026 22:10   site/css/
     4431  10-28-2026 22:10   site/css/style.css
        0  10-28-2026 22:10   site/js/
     1882  10-28-2026 22:10   site/js/app.js
        0  10-28-2026 22:10   site/logs/
    24134  10-28-2026 22:10   site/logs/access.log
     3723  10-28-2026 22:10   site/index.html
     1612  10-28-2026 22:10   site/about.html
       43  10-28-2026 22:10   site/.htaccess
---------                     -------
    35825                     10 files
ls -l site.zip
-rw-r--r-- 1 root root 4158 Oct 28 23:05 site.zip

2️⃣ zip 명령어 옵션

  • ↪️ -x, -u, -d, 압축 수준, -e

zip 명령어 옵션 가운데 -x는 담지 않을 파일을 패턴으로 뺍니다. 로그 폴더를 빼기 위해 [site/logs/*]를 지정하면 logs 폴더와 access.log가 빠지고 여덟 항목만 담깁니다.

zip -r site-nolog.zip site -x 'site/logs/*'
  adding: site/ (stored 0%)
  adding: site/css/ (stored 0%)
  adding: site/css/style.css (deflated 93%)
  adding: site/js/ (stored 0%)
  adding: site/js/app.js (deflated 87%)
  adding: site/index.html (deflated 91%)
  adding: site/about.html (deflated 87%)
  adding: site/.htaccess (deflated 9%)

셸이 [*]를 파일 이름으로 먼저 바꾸지 않게 패턴은 작은따옴표로 감쌉니다. 공식 매뉴얼은 같은 목적으로 [*] 앞에 역슬래시를 붙인 예를 들고 있습니다.

-u는 zip 파일을 만든 뒤 바뀐 파일만 다시 담습니다. index.html 끝에 한 줄을 더한 뒤 -ru로 실행하면 그 파일 하나만 [updating]으로 다시 담깁니다.

zip -ru site.zip site
updating: site/index.html (deflated 90%)

바뀐 파일이 없는 상태에서 같은 명령을 한 번 더 실행하자 아무것도 출력하지 않았고, 종료 코드는 12였습니다. 공식 매뉴얼에서 12는 zip이 할 일이 없다는 뜻입니다.

zip -ru site.zip site; echo $?
12

zip 파일 안의 항목을 지울 때는 -d를 사용합니다. [site/logs/*]를 지정하면 site.zip에서 logs 폴더 항목과 access.log가 지워집니다.

zip -d site.zip 'site/logs/*'
deleting: site/logs/
deleting: site/logs/access.log

-0부터 -9까지의 숫자는 압축 수준이고, 공식 매뉴얼 기준 기본값은 -6입니다. 같은 site 폴더를 -q로 출력 없이 세 번 압축해 크기를 비교했습니다. -u 때 index.html에 한 줄을 더한 뒤라, 이때 원래 파일 합계는 35,875바이트입니다.

zip -qr -0 level0.zip site
zip -qr level6.zip site
zip -qr -9 level9.zip site
ls -l level*.zip
-rw-r--r-- 1 root root 37433 Oct 28 23:05 level0.zip
-rw-r--r-- 1 root root  4179 Oct 28 23:05 level6.zip
-rw-r--r-- 1 root root  3874 Oct 28 23:05 level9.zip
압축 수준zip 파일 크기원래 파일 합계 대비
원래 파일 합계35,875바이트100%
-0 (압축 안 함)37,433바이트104.3%
-6 (기본값)4,179바이트11.6%
-9 (최대 압축)3,874바이트10.8%

-0으로 만든 37,433바이트는 원래 파일 합계 35,875바이트보다 컸습니다. 압축하지 않은 데이터에 항목마다 붙는 파일 이름·시각 같은 머리 정보 1,558바이트가 더해진 크기입니다. -9는 기본값보다 305바이트 작았고, 그 차이는 모두 가장 큰 파일인 access.log에서 나왔습니다.

비밀번호를 걸 때는 -e를 붙입니다. 비밀번호는 두 번 입력하고, 입력한 글자는 화면에 나오지 않습니다.

zip -e secret.zip memo.txt
Enter password:
Verify password:
  adding: memo.txt (stored 0%)

-e로 만든 secret.zip도 unzip -l로 보면 파일 이름과 크기, 날짜가 비밀번호 없이 나왔습니다. 암호화되는 것은 파일 내용뿐이라, 파일 이름까지 숨겨야 하는 자료에는 맞지 않습니다.

unzip -l secret.zip
Archive:  secret.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       71  10-28-2026 22:10   memo.txt
---------                     -------
       71                     1 file

비밀번호를 명령 줄에 바로 넣는 -P는 공식 매뉴얼이 안전하지 않다고 경고하는 옵션입니다. 같은 서버의 다른 사용자가 실행 중인 명령을 볼 수 있기 때문입니다. 매뉴얼은 zip의 표준 암호화 자체도 비교적 약하다고 설명합니다.

-e로 만든 zip을 풀 때는 unzip이 파일마다 비밀번호를 묻고, 맞게 입력하면 그 파일이 풀립니다.

unzip secret.zip -d dec
Archive:  secret.zip
[secret.zip] memo.txt password:
 extracting: dec/memo.txt

📌 주요 옵션: 이 글에서 실행한 결과

옵션하는 일이 글에서 본 결과
zip -r폴더 안의 하위 폴더와 파일까지 모두 담음-r 없이는 adding: site/ 한 줄, -r을 붙이자 .htaccess까지 열 항목이 담김
zip -x담지 않을 파일을 패턴으로 뺌site/logs/*를 빼자 logs 폴더와 access.log 없이 여덟 항목만 담김
zip -uzip 파일을 만든 뒤 바뀐 파일만 다시 담음updating: site/index.html (deflated 90%) 한 줄, 바뀐 파일이 없을 때는 출력 없이 종료 코드 12
zip -dzip 파일 안의 항목을 지움deleting: site/logs/와 deleting: site/logs/access.log
zip -q압축하는 동안 나오는 줄을 숨김-qr로 압축한 세 명령(-0, 기본값, -9) 모두 adding 줄 없이 끝남
zip -0압축하지 않고 담기만 함level0.zip이 37433바이트로 원래 파일 합계보다 큼
zip -9가장 작게 압축(기본값 -6)level9.zip 3874바이트, 기본값으로 만든 level6.zip은 4179바이트
zip -e비밀번호를 물어 내용을 암호화Enter password:와 Verify password:를 묻고 adding: memo.txt (stored 0%)
unzip -l풀지 않고 담긴 항목의 목록을 출력site.zip에 10 files, 합계 35825바이트
unzip -d풀 폴더를 지정, 없는 폴더는 새로 만듦creating: restore/site/로 시작해 restore 아래에 site 폴더 구조가 풀림
unzip -o이미 있는 파일을 묻지 않고 모두 덮어씀물음 없이 inflating 줄 다섯
unzip -n이미 있는 파일은 묻지 않고 건너뜀Archive: site.zip 줄 다음에 아무것도 나오지 않음
unzip -t풀지 않고 압축 데이터를 검사항목마다 OK와 No errors detected, 잘린 broken.zip은 End-of-central-directory signature not found
unzip -Ozip 안 파일 이름의 문자 인코딩을 지정-O CP949로 깨진 이름이 보고서.txt, 견적서.txt로 나옴
unzip -p풀린 내용을 파일로 만들지 않고 표준 출력으로 보냄파일을 만들지 않고 .htaccess의 두 줄만 나옴

📎 그 밖의 옵션: 공식 매뉴얼 기준

옵션하는 일
zip -m압축한 뒤 원래 파일과 폴더를 지움(zip 파일을 다 만든 뒤에 지우며, 공식 매뉴얼은 -T와 함께 쓰기를 권장)
zip -j폴더 경로 없이 파일 이름만 담음
zip -y심볼릭 링크가 가리키는 파일 대신 링크 그대로 담음
zip -T만든 zip 파일을 검사하고, 검사에 실패하면 원래 zip 파일을 바꾸지 않음
zip -fzip 파일에 이미 있는 항목만 바뀐 파일로 바꾸고, 새 파일은 더하지 않음
zip -i지정한 패턴에 맞는 파일만 담음
zip -P비밀번호를 명령 줄에 바로 적음(공식 매뉴얼은 안전하지 않다고 경고)
unzip -jzip 안의 폴더 구조를 만들지 않고 파일만 한 폴더에 풂
unzip -x풀지 않을 항목을 지정
unzip -q푸는 동안 나오는 줄을 숨김
unzip -u디스크에 없는 파일과 더 새로운 파일만 풂
unzip -v목록에 압축 방식, 압축된 크기, 비율, CRC까지 출력

3️⃣ unzip 명령어 사용법

  • ↪️ 리눅스 zip 풀기와 -d, -o, -n

리눅스에서 zip 파일을 풀 때는 unzip 뒤에 zip 파일 이름을 적습니다. -d로 풀 폴더를 정하지 않으면 지금 있는 폴더에 풀리므로(공식 매뉴얼 기준), 이번에는 restore 폴더를 지정했습니다.

unzip site.zip -d restore
Archive:  site.zip
   creating: restore/site/
   creating: restore/site/css/
  inflating: restore/site/css/style.css
   creating: restore/site/js/
  inflating: restore/site/js/app.js
  inflating: restore/site/index.html
  inflating: restore/site/about.html
  inflating: restore/site/.htaccess

-d로 지정한 폴더가 없으면 unzip이 새로 만들고, 그 아래에 site 폴더 구조가 그대로 풀립니다.

같은 자리에 다시 풀면 unzip은 이미 있는 파일을 만날 때마다 멈추고 덮어쓸지 묻습니다. [N]one을 고르면 남은 파일까지 하나도 덮어쓰지 않고 끝납니다.

unzip site.zip -d restore
Archive:  site.zip
replace restore/site/css/style.css? [y]es, [n]o, [A]ll, [N]one, [r]ename: N

묻지 않고 처리할 때는 -o나 -n을 붙입니다. -o는 있는 파일을 모두 덮어쓰고, -n은 있는 파일을 건너뜁니다. 공식 매뉴얼이 -o를 위험한 옵션으로 적고 있어, -o는 덮어써도 되는 폴더인지 먼저 확인한 뒤 붙입니다.

unzip -o site.zip -d restore
Archive:  site.zip
  inflating: restore/site/css/style.css
  inflating: restore/site/js/app.js
  inflating: restore/site/index.html
  inflating: restore/site/about.html
  inflating: restore/site/.htaccess
unzip -n site.zip -d restore
Archive:  site.zip

파일이 모두 이미 있는 자리에 -n으로 풀면 Archive 줄 다음에 아무것도 나오지 않습니다.

zip 파일 안의 일부만 풀 때는 zip 파일 이름 뒤에 경로나 패턴을 적습니다. [site/css/*]를 지정하면 css 폴더와 style.css만 풀립니다.

unzip site.zip 'site/css/*' -d part
Archive:  site.zip
   creating: part/site/css/
  inflating: part/site/css/style.css

4️⃣ unzip 오류

  • ↪️ End-of-central-directory와 파일 이름 깨짐

다른 서버에서 받은 zip 파일은 풀기 전에 unzip -t로 검사합니다. 압축 데이터에 문제가 없으면 항목마다 OK가 나오고, 마지막 줄에 [No errors detected]가 나옵니다.

unzip -t site.zip
Archive:  site.zip
    testing: site/                    OK
    testing: site/css/                OK
    testing: site/css/style.css       OK
    testing: site/js/                 OK
    testing: site/js/app.js           OK
    testing: site/index.html          OK
    testing: site/about.html          OK
    testing: site/.htaccess           OK
No errors detected in compressed data of site.zip.

전송이 끊겨 뒷부분이 잘린 zip은 [End-of-central-directory signature not found]로 끝났습니다. -d로 logs 항목을 지운 뒤 2,436바이트가 된 site.zip에서 앞 2,000바이트만 남긴 broken.zip을 -t로 검사한 결과입니다.

unzip -t broken.zip
Archive:  broken.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of broken.zip or
        broken.zip.zip, and cannot find broken.zip.ZIP, period.

unzip은 zip 파일 맨 끝에 있는 파일 목록(central directory)을 먼저 읽습니다. 그래서 뒷부분이 잘린 broken.zip은 첫 항목도 검사하지 못했습니다.

zip이 아닌 파일을 넣어도 같은 문구가 나왔습니다. tar로 묶은 site.tar.gz를 unzip으로 열자 같은 오류로 끝났고, tar.gz 파일은 tar 명령어로 풉니다.

unzip site.tar.gz
Archive:  site.tar.gz
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of site.tar.gz or
        site.tar.gz.zip, and cannot find site.tar.gz.ZIP, period.

Windows에서 만든 zip 파일은 파일 이름이 UTF-8이 아닌 Windows 문자 인코딩으로 들어 있는 경우가 있습니다. 이름을 CP949로 넣은 report-win.zip을 UTF-8 서버에서 unzip -l로 열자, 파일 이름이 알아볼 수 없는 기호로 깨져 나왔습니다.

unzip -l report-win.zip
Archive:  report-win.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       26  10-28-2026 22:10   ║╕░э╝н.txt
       17  10-28-2026 22:10   ░▀└√╝н.txt
---------                     -------
       43                     2 files

-O 뒤에 그 zip을 만든 Windows의 문자 인코딩을 적으면 이름이 제대로 나오고, 같은 옵션으로 푼 파일도 원래 이름으로 만들어집니다.

unzip -O CP949 -l report-win.zip
Archive:  report-win.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       26  10-28-2026 22:10   보고서.txt
       17  10-28-2026 22:10   견적서.txt
---------                     -------
       43                     2 files
unzip -O CP949 report-win.zip -d win
Archive:  report-win.zip
  inflating: win/보고서.txt
  inflating: win/견적서.txt

unzip 도움말 기준으로 -O는 DOS·Windows에서 만든 zip에, -I는 그 밖의 시스템에서 만든 zip에 지정하는 옵션입니다.

압축을 풀다 나온 오류 문구와 다음에 확인할 것은 아래와 같습니다.

출력뜻다음에 확인할 것
End-of-central-directory signature not foundzip 파일 끝의 파일 목록을 찾지 못함 — 끝이 잘린 파일이거나 zip이 아닌 파일원본과 파일 크기를 비교하고 다시 받기 · tar.gz는 tar로
cannot find or open그 이름의 파일이 지금 폴더에 없음ls로 파일 이름과 위치
skipping: … incorrect password비밀번호가 세 번 틀려 그 파일을 건너뜀(종료 코드 82)비밀번호의 대소문자와 입력 언어
파일 이름이 기호로 깨짐이름이 Windows 문자 인코딩으로 저장됨-O 뒤에 그 인코딩(CP949 등)

🔲 zip 명령어 시뮬레이터

아래 시뮬레이터에서 zip으로 압축하고, unzip으로 목록을 보거나 푸는 과정을 직접 입력해 볼 수 있습니다.

zip 명령어 시뮬레이터Zip 3.0 · UnZip 6.00
[root@server work]#
브라우저 안에서만 동작하고 실제 파일은 압축하지 않습니다. 압축률은 실측 값이고, 시뮬레이터에서 새로 만든 파일은 추정 값입니다. ↑↓ 로 앞에서 쓴 명령을 다시 불러옵니다.

🔢 FAQ & 추천 콘텐츠

gzip으로 압축한 .gz 파일을 unzip으로 열자 [End-of-central-directory signature not found]로 끝났습니다. [gzip -d readme.txt.gz]로 풀자 readme.txt.gz가 readme.txt로 돌아왔습니다. 여러 파일을 tar로 묶은 뒤 gzip으로 압축한 .tar.gz는 tar로 한 번에 풉니다.

확인한 AlmaLinux 9 서버에서 zip과 unzip은 각각 zip, unzip 패키지가 설치한 명령이었습니다. 그래서 RHEL 계열은 [sudo dnf install zip unzip], Debian 계열은 [sudo apt install zip unzip]으로 설치합니다(Debian 공식 패키지 목록 기준).

unzip -p 뒤에 zip 파일과 그 안의 경로를 적으면 내용이 화면으로 바로 나옵니다. [unzip -p site.zip site/.htaccess]로 실행하자 파일을 만들지 않고 .htaccess의 두 줄만 나왔습니다.

ℹ️ 제휴 안내
본 사이트의 콘텐츠에는 제휴 링크가 포함되어 있습니다. 방문자가 이 링크를 통해 상품 또는 서비스를 구매하면 본 사이트는 판매처로부터 수수료를 지급받습니다. 이 과정에서 구매자가 지불하는 금액(이벤트 할인 시 금액이 내려갑니다↓)은 오르지 않습니다. 게시된 가격·할인·재고 정보는 작성 시점 기준이며 실제와 다를 수 있으므로, 구매 전 판매처에서 최종 확인하시기 바랍니다. 상품 선정과 평가는 자체 기준에 따라 작성되며, 수수료 지급 여부가 소개 순서나 평가 내용에 영향을 주지 않습니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

인간임을 증명하세요: 4   +   8   =