728x90
반응형
개요
ubuntu 환경에서 "*.7z" 압축 파일을 다루기 위하여 "7zip"을 설치하고 활용하는 방법을 정리합니다.
사용환경
- OS : Ubuntu 20.04
- SBC : NVIDIA Jetson AGX ORIN
7zip 설치하기
"7zip" 패키지는 다음과 같이 설치합니다.
orin@ubuntu:/opt/hunature/flpd$ sudo apt install p7zip-full p7zip-rar
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
p7zip
The following NEW packages will be installed:
p7zip p7zip-full p7zip-rar
0 upgraded, 3 newly installed, 0 to remove and 125 not upgraded.
Need to get 1,417 kB of archives.
After this operation, 5,624 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 p7zip arm64 16.02+dfsg-7build1 [317 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 p7zip-full arm64 16.02+dfsg-7build1 [1,058 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports focal/multiverse arm64 p7zip-rar arm64 16.02-3build1 [42.1 kB]
Fetched 1,417 kB in 3s (491 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package p7zip.
(Reading database ... 180105 files and directories currently installed.)
Preparing to unpack .../p7zip_16.02+dfsg-7build1_arm64.deb ...
Unpacking p7zip (16.02+dfsg-7build1) ...
Selecting previously unselected package p7zip-full.
Preparing to unpack .../p7zip-full_16.02+dfsg-7build1_arm64.deb ...
Unpacking p7zip-full (16.02+dfsg-7build1) ...
Selecting previously unselected package p7zip-rar.
Preparing to unpack .../p7zip-rar_16.02-3build1_arm64.deb ...
Unpacking p7zip-rar (16.02-3build1) ...
Setting up p7zip (16.02+dfsg-7build1) ...
Setting up p7zip-full (16.02+dfsg-7build1) ...
Setting up p7zip-rar (16.02-3build1) ...
Processing triggers for man-db (2.9.1-1) ...
라즈비안 OS에 설치할 때는 "p7zip-rar" 패키지는 지원하지 않으므로, "p7zip-full" 패키지만 설치하면 됩니다.
"7z" 사용 예시
파일 및 폴더의 압축은 "a" 명령을 이용합니다.
orin@ubuntu:/opt/hunature/flpd$ 7z a ../TrackingTools.7z TrackingTools/
7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,32 bits,4 CPUs LE)
Scanning the drive:
2 folders, 9 files, 54606 bytes (54 KiB)
Creating archive: ../TrackingTools.7z
Items to compress: 11
Files read from disk: 8
Archive size: 14171 bytes (14 KiB)
Everything is Ok
"-m<압축률 단계>" : 압축률을 조정할 수 있습니다. 압축률 숫자가 클 수록 압축률이 높아지는 대신 CPU 자원 소모량이 커지고 속도가 더 느려집니다.
"-r" : 하위 폴더들을 포함하여 압축합니다.
"-x" : 특정 파일이나 폴더를 제외하여 압축합니다.
# "./myProj" 폴더 아래의 모든 파일들을 최고 압축률로 압축합니다. 압축 시, ".git" 폴더들은 제외합니다.
7z a myProj.7z -m9 -r -x!.git
압축된 "*.7z" 파일을 해제는 "x" 명령을 이용합니다.
orin@ubuntu:/opt/hunature$ 7z x TrackingTools.7z
7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,32 bits,4 CPUs LE)
Scanning the drive for archives:
1 file, 14171 bytes (14 KiB)
Extracting archive: TrackingTools.7z
--
Path = TrackingTools.7z
Type = 7z
Physical Size = 14171
Headers Size = 362
Method = LZMA2:16
Solid = +
Blocks = 1
Everything is Ok
Folders: 2
Files: 9
Size: 54606
Compressed: 14171
"7z" 명령 및 추가 설정
"7z"의 기본 명령은 다음과 같습니다.
a : Add files to archive
b : Benchmark
d : Delete files from archive
e : Extract files from archive (without using directory names)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
"7z"의 추가 설정은 다음과 같습니다.
-- : Stop switches parsing
-ai[r[-|0]]{@listfile|!wildcard} : Include archives
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
-an : disable archive_name field
-bb[0-3] : set output log level
-bd : disable progress indicator
-bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
-bt : show execution time statistics
-i[r[-|0]]{@listfile|!wildcard} : Include filenames
-m{Parameters} : set compression Method
-mmt[N] : set number of CPU threads
-o{Directory} : set Output directory
-p{Password} : set Password
-r[-|0] : Recurse subdirectories
-sa{a|e|s} : set Archive name mode
-scc{UTF-8|WIN|DOS} : set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
-scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
-sdel : delete files after compression
-seml[.] : send archive by email
-sfx[{name}] : Create SFX archive
-si[{name}] : read data from stdin
-slp : set Large Pages mode
-slt : show technical information for l (List) command
-snh : store hard links as links
-snl : store symbolic links as links
-sni : store NT security information
-sns[-] : store NTFS alternate streams
-so : write data to stdout
-spd : disable wildcard matching for file names
-spe : eliminate duplication of root folder for extract command
-spf : use fully qualified file paths
-ssc[-] : set sensitive case mode
-ssw : compress shared files
-stl : set archive timestamp from the most recently modified file
-stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
-stx{Type} : exclude archive type
-t{Type} : Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options
-v{Size}[b|k|m|g] : Create volumes
-w[{path}] : assign Work directory. Empty path means a temporary directory
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
-y : assume Yes on all queries
참고자료
- "How to Install 7Zip on Ubuntu 18.04":https://www.digitalocean.com/community/tutorials/install-7zip-ubuntu
'Linux,Unix,BSD' 카테고리의 다른 글
[Embedded] Orange Pi 5에 Armbian을 이용하여 USB memory 부팅 시도기 (실패) (0) | 2023.02.14 |
---|---|
tar 파일 묶을 때, 특정 폴더 및 파일 제외하기 (0) | 2023.01.10 |
[linux] 일반 계정으로 80 포트로 웹 서비스하는 방법들 (0) | 2022.06.24 |
[shell] Bad Substitution(bash) (0) | 2022.06.23 |
[shell] 문자열 잘라내기(substring) (0) | 2022.06.13 |