最新消息:20210917 已从crifan.com换到crifan.org

【已解决】CentOS中去解压7zip格式的7z文件

CentOS crifan 7170浏览 0评论

折腾:

【记录】crifan.org的WordPress网站从Linode搬家到腾讯云香港服务器

期间,需要去腾讯云香港CVM服务器中CentOS 7中去解压7z文件:

<pre class="prettyprint lang-bsh">[root@VM_0_11_centos wwwroot]# ls -lh
total 8.5G
drwxr-xr-x 3 www  www  4.0K Dec 25 21:17 default
drwxr-xr-x 2 www  www  4.0K Dec 25 21:41 www.crifan.org
-rw-r--r-- 1 root root 8.5G Dec 26 22:20 www.crifan.org_allFiles_20181225.7z

centos 7z uncompress

tar – Extract 7z files with standard linux tools? – Super User

7zip File: How to Uncompress 7z files on Ubuntu, Debian, Fedora

用e参数

[root@VM_0_11_centos wwwroot]# 7za e www.crifan.org_allFiles_20181225.7z 
-bash: 7za: command not found

7zip – How can I uncompress a *.7z file? – Ask Ubuntu

用7z x

结果才想起来,还没安装7z呢。。。

参考之前自己的:

【记录】CentOS下用7zip压缩文件去备份网站

去安装

https://sourceforge.net/projects/p7zip/files/p7zip/16.02/p7zip_16.02_src_all.tar.bz2/download

-》

https://nchc.dl.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2

去服务器中下载

[root@VM_0_11_centos tool]# tar xvf p7zip_16.02_src_all.tar.bz2
[root@VM_0_11_centos tool]# ll -lh
total 4.1M
drwx--S--- 11 www  ftp  4.0K Jul 14  2016 p7zip_16.02
-rw-r--r--  1 root root 4.1M Jul 14  2016 p7zip_16.02_src_all.tar.bz2
cd p7zip_16.02
make &amp;&amp; make install
...ake[1]: Leaving directory `/data/wwwroot/tool/p7zip_16.02/CPP/7zip/Bundles/Alone'
./install.sh /usr/local/bin /usr/local/lib/p7zip /usr/local/man /usr/local/share/doc/p7zip 
- installing /usr/local/bin/7za
- installing /usr/local/man/man1/7z.1
- installing /usr/local/man/man1/7za.1
- installing /usr/local/man/man1/7zr.1
- installing /usr/local/share/doc/p7zip/README
- installing /usr/local/share/doc/p7zip/ChangeLog
- installing HTML help in /usr/local/share/doc/p7zip/DOC

看看版本:

[root@VM_0_11_centos p7zip_16.02]# which 7za
/usr/local/bin/7za
[root@VM_0_11_centos p7zip_16.02]# 7za --version


Command Line Error:
Unknown switch:
--version
[root@VM_0_11_centos p7zip_16.02]# 7za --help

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs x64)

Usage: 7za &lt;command&gt; [&lt;switches&gt;...] &lt;archive_name&gt; [&lt;file_names&gt;...]
       [&lt;@listfiles...&gt;]

&lt;Commands&gt;
  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

&lt;Switches&gt;
  -- : 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

可见:

x : eXtract files with full paths

7za x www.crifan.org_allFiles_20181225.7z

去解压:

【总结】

此处去CentOS要解压7z,需要先去安装:

先用浏览器打开:

https://sourceforge.net/projects/p7zip/files/p7zip/16.02/p7zip_16.02_src_all.tar.bz2/download

会自动下载,得到下载地址,然后去服务器中用wget下载:

wget https://nchc.dl.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2

解压:

tar xvf p7zip_16.02_src_all.tar.bz2

安装

cd p7zip_16.02
make && make install

确认已安装:

which 7za
7za --help

然后再去解压7z

7za x www.crifan.org_allFiles_20181225.7z

【后记】

How to Extract 7zip files in CentOS 7 | Unzip 7z CentOS

sudo yum install epel-release
sudo yum install p7zip
7za x file.7z

有空去试试。

【后记2】

折腾:

【未解决】恢复crifan.org的WordPress到Vultr的CentOS7的OneinStack中

期间,去CentOS7中,突然想到,可以不用从源码中安装,去搜索7z相关的工具:

[root@crifan book.crifan.org]# yum search 7z
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
 * base: mirror.newmediaexpress.com
 * epel: mirrors.cat.pdx.edu
 * extras: mirror.newmediaexpress.com
 * updates: mirror.newmediaexpress.com
=========================================================================== N/S matched: 7z ============================================================================
p7zip-gui.x86_64 : 7zG - 7-Zip GUI version
p7zip-plugins.x86_64 : Additional plugins for p7zip
p7zip.x86_64 : Very high compression ratio file archiver
p7zip-doc.noarch : Manual documentation and contrib directory

  Name and summary matches only, use "search all" for everything.

可以看到是有:

之前就见过的p7zip

去安装试试:

[root@crifan book.crifan.org]# yum install p7zip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                             |  17 kB  00:00:00     
 * base: mirror.newmediaexpress.com
 * epel: mirror.rackspace.com
 * extras: mirror.newmediaexpress.com
 * updates: mirror.newmediaexpress.com
base                                                                                                                                             | 3.6 kB  00:00:00     
epel                                                                                                                                             | 4.7 kB  00:00:00     
extras                                                                                                                                           | 3.4 kB  00:00:00     
updates                                                                                                                                          | 3.4 kB  00:00:00     
(1/3): epel/x86_64/updateinfo                                                                                                                    | 1.0 MB  00:00:00     
(2/3): epel/x86_64/primary_db                                                                                                                    | 6.7 MB  00:00:00     
(3/3): updates/7/x86_64/primary_db                                                                                                               | 5.0 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package p7zip.x86_64 0:16.02-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                               Arch                                   Version                                        Repository                            Size
========================================================================================================================================================================
Installing:
 p7zip                                 x86_64                                 16.02-10.el7                                   epel                                 604 k

Transaction Summary
========================================================================================================================================================================
Install  1 Package

Total download size: 604 k
Installed size: 1.7 M
Is this ok [y/d/N]: y
Downloading packages:
p7zip-16.02-10.el7.x86_64.rpm                                                                                                                    | 604 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : p7zip-16.02-10.el7.x86_64                                                                                                                            1/1 
  Verifying  : p7zip-16.02-10.el7.x86_64                                                                                                                            1/1 

Installed:
  p7zip.x86_64 0:16.02-10.el7                                                                                                                                           

Complete!

看看安装的位置,版本

[root@crifan book.crifan.org]# which 7z
/usr/bin/which: no 7z in (/usr/local/php/bin:/usr/local/tengine/sbin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@crifan book.crifan.org]# which 7za
/usr/bin/7za
[root@crifan book.crifan.org]# 7za --help

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Virtual CPU 82d9ed4018dd (50654),ASM,AES-NI)

Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]

<Commands>
  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

<Switches>
  -- : 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

和之前的7z是一样的用法,核心参数是:

  x : eXtract files with full paths

7za x book.crifan.org_allFiles_20190510.7z

即可。

转载请注明:在路上 » 【已解决】CentOS中去解压7zip格式的7z文件

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.188 seconds, using 23.37MB memory