Tuesday, December 4, 2012

Centos Linux and 7z

Files with the extension of .7z indicates its a 7-zip compressed files in unicode format. To access files within the 7z, you will need to uncompress or extract the 7z file. By default, compression uses LZMA or Lempel–Ziv–Markov chain algorithm, which is an algorithm used to perform lossless data compression.

The program used to access 7z files;

  1. Windows: 7-zip
  2. Centos Linux: p7zip

Main differences of 7z and tar, is that 7z is meant to be more portable. This includes dropping of the user/group permission of files. I will demonstrate based on Centos 6.

A. Creating a 7z file
Step 1: Installing p7zip
yum install p7zip

Step 2: Compress files in directory named "examples" into the file myfiles.7z
7za a myfiles.7z

Step 3: List files within myfiles.7z
7za l myfiles.7z

Example output as below (note - no user/group info)

7-Zip (A) [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Listing archive: scripts.7z

--
Path = scripts.7z
Type = 7z
Method = LZMA
Solid = +
Blocks = 1
Physical Size = 4319
Headers Size = 365

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2012-12-04 09:17:15 ....A          179         3954  examples/svn-auth-users
2012-12-04 09:17:15 ....A           35               examples/tboxmy.sh
2012-12-04 09:17:15 ....A         1004               examples/menusnapshot.sh
2012-12-04 09:17:15 D....            0            0  examples 
------------------- ----- ------------ ------------  ------------------------
                                  1218         3954  3 files, 1 folders


Optional steps;
Verify 7z file
7za t myfiles.7z


B. Extracting a 7z file

Step 1: Extract to current directory
7za e myfiles.7z


No comments:

Blog Archive