解决:gzip -c test.txt > /root/test.gz,文件流重定向,解压也是,gunzip -c /root/test.gz > ./test.txt
经验:更常用的命令tar同样可以解压*.gz,参数为-c
附gzip帮助文件
GZIP(1) General Commands Manual GZIP(1)
NAME
gzip, gunzip, zcat - compress or expand files
SYNOPSIS
gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ]
gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ]
zcat [ -fhLV ] [ name ... ]
OPTIONS
-a --ascii
Ascii text mode: convert end-of-lines using local conventions.
This option is supported only on some non-Unix systems. For
MSDOS, CR LF is converted to LF when compressing, and LF is con‐
verted to CR LF when decompressing.
-c --stdout --to-stdout
Write output on standard output; keep original files unchanged.
If there are several input files, the output consists of a
sequence of independently compressed members. To obtain better
compression, concatenate all input files before compressing
them.
-d --decompress --uncompress
Decompress.
-f --force
Force compression or decompression even if the file has multiple
links or the corresponding file already exists, or if the com‐
pressed data is read from or written to a terminal. If the input
data is not in a format recognized by gzip, and if the option
--stdout is also given, the input data without change to
the standard output: let zcat behave as cat. If -f is not
given, and when not running in the background, gzip prompts to
verify whether an existing file should be overwritten.
-h --help
Display a help screen and quit.
-l --list
For each compressed file, list the following fields:
compressed size: size of the compressed file
uncompressed size: size of the uncompressed file
ratio: compression ratio (0.0% if unknown)
uncompressed_name: name of the uncompressed file
The uncompressed size is given as -1 for files not in gzip for‐
mat, such as compressed .Z files. To get the uncompressed size
for such a file, you can use:
zcat file.Z | wc -c
In combination with the --verbose option, the following fields
are also displayed:
method: compression method
crc: the 32-bit CRC of the uncompressed data
date & time: time stamp for the uncompressed file
The compression methods currently supported are deflate, com‐
press, lzh (SCO compress -H) and pack. The crc is given as
ffffffff for a file not in gzip format.
With --name, the uncompressed name, date and time are those
stored within the compress file if present.
With --verbose, the size totals and compression ratio for all
files is also displayed, unless some sizes are unknown. With
--quiet, the title and totals lines are not displayed.
-L --license
Display the gzip license and quit.
-n --no-name
When compressing, do not save the original file name and time
stamp by default. (The original name is always saved if the name
had to be truncated.) When decompressing, do not restore the
original file name if present (remove only the gzip suffix from
the compressed file name) and do not restore the original time
stamp if present ( it from the compressed file). This option
is the default when decompressing.
-N --name
When compressing, always save the original file name and time
stamp; this is the default. When decompressing, restore the
original file name and time stamp if present. This option is
useful on systems which have a limit on file name length or when
the time stamp has been lost after a file transfer.
-q --quiet
Suppress all warnings.
-r --recursive
Travel the directory structure recursively. If any of the file
names specified on the command line are directories, gzip will
descend into the directory and compress all the files it finds
there (or decompress them in the case of gunzip ).
-S .suf --suffix .suf
When compressing, use suffix .suf instead of .gz. Any non-empty
suffix can be given, but suffixes other than .z and .gz should
be avoided to avoid confusion when files are transferred to
other systems.
When decompressing, add .suf to the beginning of the list of
suffixes to try, when deriving an output file name from an input
file name.
pack(1).
-t --test
Test. Check the compressed file integrity.
-v --verbose
Verbose. Display the name and percentage rection for each file
compressed or decompressed.
-V --version
Version. Display the version number and compilation options then
quit.
-# --fast --best
Regulate the speed of compression using the specified digit #,
where -1 or --fast indicates the fastest compression method
(less compression) and -9 or --best indicates the slowest com‐
pression method (best compression). The default compression
level is -6 (that is, biased towards high compression at expense
of speed).
② 如何开启gzip压缩方法大全
IIS6.0启用Gzip压缩的方法:
1、新建Web服务扩展(如下图)
dll路径:“c:windowssystem32inetsrvgzip.dll”,然后启用。
2、网站服务中开启HTTP压缩支持(如下图)
临时目录需要给IIS用户读写权限。
3、修改IIS配置文件MetaBase.xml
文件路径:“c:windowssystem32inetsrv”(请先备份至他处),打开后搜索“HcDynamicCompressionLevel”,并修改(确定已备份)“Compression/deflate”和“Compression/gzip”两个片段的内容。下面的图n和图b所修改的内容用意是将js、css和php加入到压缩的范畴,数字9代表压缩等级。
(图n)
(图b)
4、重启IIS服务使之生效
——————————————————分分割割—————————————————
Apache启用Gzip压缩的方法:
1、开启模块并添加配置项目
a、vi /etc/httpd/conf/httpd.conf
b、查找LoadMole (/LoadMole),加入“LoadMole deflate_mole moles/mod_deflate.so”这行
c、添加配置项目(下段内容)
复制代码代码如下:
<IfMole mod_deflate.c>
# 压缩等级 9
DeflateCompressionLevel 9
# 压缩类型 html、xml、php、css、js
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript application/x-httpd-php
AddOutputFilter DEFLATE js css
</IfMole>
2、重启apache使之生效
service httpd start
——————————————————分分割割—————————————————
检测是否支持Gzip
END
注意事项
1. 在编辑MetaBase.xml前需要停止IIS,可以使用 net stop iisadmin
2. 修改完成后开启iisadmin服务,并执行iisreset命令
关于SEO的测试
压缩是否对SEO有影响,经测试,开启后仍然可以被很好的收录。
③ GZIP 与zip区别
一、主体不同
1、GZIP:最早由Jean-loup Gailly和Mark Adler创建,用于UNⅨ系统的文件压缩。
2、ZIP:ZIP文件格式是一种数据压缩和文档储存的文件格式。
二、特点不同
1、GZIP:基础是DEFLATE,DEFLATE是LZ77与哈夫曼编码的一个组合体。DEFLATE最初是作为LZW以及其它受专利保护的数据压缩算法的替代版本而设计的。
2、ZIP:是一种相当简单的分别压缩每个文件的存档格式。分别压缩文件允许不必读取另外的数据而检索独立的文件。
三、优点不同
1、GZIP:可以减少存储空间,通过网络传输文件时,可以减少传输的时间。
2、ZIP:支持基于对称加密系统的一个简单的密码,已知有严重的缺陷,已知明文攻击,字典攻击和暴力攻击。
④ 如何进行网站的GZIP压缩处理
下面”舒宇卓创站长“将和大家一起分享一下,希望对咱们站长有所帮助! 1.开启网页GZIP压缩有什么好处? Gzip开启以后会将输出到用户浏览器的数据进行压缩的处理,这样就会减小通过网络传输的数据量,提高浏览的速度。 进而对于搜索引擎的收录也有一定的好处,也大大提高了我们的用户体验度。 2.如何启用IIS的Gzip压缩功能: 首先要有网站管理权限和服务器远程管理权限
步骤如下: 第一、如果你需要压缩静态文件(HTML),需要在硬盘上建一个目录,并给它“IUSR_机器名”这个用户的写权限。如果压缩动态文件(PHP,asp,aspx)就不需要了,因为它的页面是每次都动态生成的,压缩完就放弃。打开Internet信息服务(IIS)管理器,右击“网站”—>“属性”(注意:这里的网站是整个网站文件不是某个网站目录),之后选择“服务”。在“HTTP压缩”框中选中“压缩应用程序文件”和“压缩静态文件”,按需要设置“临时目录”和“临时目录的最大限制”。 第二、在Internet信息服务(IIS)管理器,右击“Web服务扩展”—>“增加一个新的Web服务扩展”,在“新建Web服务扩展”框中输入扩展名“HTTP Compression”,添加“要求的文件”为C:\WINDOWS\system32\inetsrv\gzip.dll,其中Windows系统目录根据您的安装可能有所不同,选中“设置扩展状态为允许”;这时候静态内容是可以压缩的,但是对于动态内容,aspx文件却不在压缩范围内。因为默认的可压缩文件并没有这个扩展名。而管理界面中你又找不到可以增加扩展名的地方,这时候只能去修改它的配置文件了。 第三、使用文本编辑器打开C:\Windows\System32\inetsrv\MetaBase.xml(建议先备份),查找 IIsCompressionScheme标签,有三个相同名字的段,分别是deflate,gzip,Parameters,第三段不用管它,前两段有基本相同的参数,HcDynamicCompressionLevel,设置压缩率,取值0~10,0不压缩,10最高压缩率,这里设置成9,9是性价比最高的一个。HcFileExtensions,需要压缩的静态文件扩展名,默认只有htm,html,txt,可以把js,css,xml添加进去。建议按原来的格式,用换行作为分隔。
⑤ zip压缩和gzip压缩有何区别,各有什么优点谢谢!
gzip是linux下面用的格式,一般在Linux下解压,如果用Windows下的程序解压有可能丢失其中某些文件或属性。
⑥ 网站建设中的gzip压缩是什么意思
GZIP格式已经成为使用非常普遍的一种数据压缩格式,或者说一种文件格式。HTTP协议上的GZIP编码是一种用来改进WEB应用程序性能的技术。大流量的WEB站点常常使用GZIP压缩技术来让用户感受更快的速度。减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间。gzip 是在 Linux 系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用。
另外,你建的如果不是大型站点。只是一个企业站或一个小社区小门户不需要用这个技术。只需要把代码优化做好一点选个速度快一点的服务器就行了。我做网站滴
⑦ 什么是GZIP压缩 网页GZIP压缩是什么意思
这一般是指WWW服务器中安装的一个功能,当有人来访问这个服务器中的网站时,服务器中的这个功能就将网页内容压缩后传输到来访的电脑浏览器中显示出来.一般对纯文本内容可压缩到原大小的40%.这样传输就快了,效果就是你点击网址后会很快的显示出来.当然这也会增加服务器的负载.
一般服务器中都安装有这个功能模块的.
⑧ 怎样调用Gzip将指定的文件进行压缩并备份(
命令: gzip语法:gzip [选项] 压缩(解压缩)的文件名 -c 将输出写到标准输出上,并保留原有文件。 -d 将压缩文件解压。 -l 对每个压缩文件,显示下列字段: (1)压缩文件的大小 (2)未压缩文件的大小 (3)压缩比 未压缩文件的名字 -r 递...
⑨ gzip压缩 是什么
这一般是指WWW服务器中安装的一个功能,当有人来访问这个服务器中的网站时,服务器中的这个功能就将网页内容压缩后传输到来访的电脑浏览器中显示出来.一般对纯文本内容可压缩到原大小的40-70左右%.这样传输就快了,效果就是你点击网址后会很快的显示出来.当然这也会增加服务器的负载.一般服务器中都安装有这个功能模块的.
网站的访问速度是由多个因素所共同决定的,这些因素例如应用程序的响应速度、网络带宽、服务器性能、与客户端之间的网络传输速度等等。其中最重要的一个因素是应用程序本身的响应速度,因此当你为网站性能所苦恼时,你第一个需要着手进行处理的便是尽可能的提升应用程序的执行速度,你可以使用缓存或者是优化代码的执行效率来提升应用程序的速度。
在确保您的应用程序的性能已经达到足够好,同时服务器的性能也完全满足的情况下,不妨来试试网页压缩来进一步提升网页的浏览速度,而且非常重要的是,它完全不需要任何的成本,只不过是会让您的服务器CPU占用率稍微提升一两个百分点而已或者更少。
网页压缩是一项由 WEB 服务器和浏览器之间共同遵守的协议,也就是说 WEB 服务器和浏览器都必须支持该技术,所幸的是现在流行的浏览器都是支持的,包括 IE、FireFox、Opera 等;服务器有 Apache 和 IIS 等。双方的协商过程如下:
1.首先浏览器请求某个 URL 地址,并在请求的头 (head) 中设置属性 accept-encoding 值为 gzip, deflate,表明浏览器支持 gzip 和 deflate 这两种压缩方式(事实上 deflate 也是使用 gzip 压缩协议);
2.WEB 服务器接收到请求后判断浏览器是否支持压缩,如果支持就传送压缩后的响应内容,否则传送不经过压缩的内容;
3.浏览器获取响应内容后,判断内容是否被压缩,如果是则解压缩,然后显示响应页面的内容。
在实际的应用中我们发现压缩的比率往往在 3 到 10 倍,也就是本来 50k 大小的页面,采用压缩后实际传输的内容大小只有 5 至 15k 大小,这可以大大节省服务器的网络带宽,同时如果应用程序的响应足够快时,网站的速度瓶颈就转到了网络的传输速度上,因此内容压缩后就可以大大的提升页面的浏览速度。
⑩ linux 中 用gzip 如何压缩目录
linux 中用gzip 压缩目录步骤如下:
1、打开linux客户端。