Explain the concept of
the two most common window compression: * zip * .7z suffix compressed file.
Strapping tools on Linux are:
File extension | Explanation |
---|---|
*.zip | packaged compressed zip file |
*.rar | rar file compression program |
* .7z | 7zip file compression program |
* tar | tar packaged, uncompressed file |
*.gz | gzip packaged, compressed file |
*.xz | xz compressed program files |
* .Bz2 | program bzip2 compressed file |
* .Tar.gz | packaged tar, gzip file compression program |
* .tar.bz2 | tar package, bzip2 compressed program files |
* .tar.7z | tar package, 7z file compression program |
zip compression Packager
zip -r -q -o name you want to compress archive folder
-r :表示递归打包包含子目录的全部内容
-q:表示为安静模式,即不向屏幕输出信息
-o: 表示输出文件,户名要紧跟打包输出文件名
设置压缩的级别9和1(9最大,1最小),9表示体积最小但耗时,1表示压缩最快但体积大。
-e:表示可以创建加密压缩包
-l:将LF转化为CR+LF
————注意:在windows为CR+LF(Carriage-Return+Line-Feed:回车加换行),而在Linux/Unix上位LF(换行),所以如果不加处理的情况下,
在Linux上编辑的文本,在Windows系统上打开可能是没有换行的,那么就可以使用-l来达成目的
Using the unzip command to expand the zip file
把压缩文件解压到当前目录
unzip 压缩文件
使用安静模式,将文件解压到指定目录,如果目录不存在则自动创建
unzip -q 压缩文件 -d 指定的目录
只看压缩包的内容
unzip -l shiyanlou.zip
————通常Windows系统上面创建的压缩文件,如果有中文或以中文作为文件名时,会默认采用GBK或其他编码,而Linux则使用UTF-8编码
为了防止中文乱码 使用-O(大写)指定编码类型
unzip -O GBK 压缩文件名
tar package tool
tar -P -cf shiyanlou.tar /hom/shiyanlou/Desktop
-P:保留觉得路径符
-c:表示创建一个tar包文件,-f用于指定创建的文件名,注意文件名必须紧跟-f参数。
解包到指定文件
tar -xf 压缩包 -C 指定的文件(已存在)
只查看不解包
tar -tf 压缩包
使用gzip来压缩文件
tar -czf shiyanlou.tar.gz /home/shiyanlou/Desktop
解压*.tar.gz文件
tar -xzf shiyanlou.tar.gz