linux 常用命令压缩,解压缩

实例         tar -czf domain.tar Domain/

tar -czf Dossiers.tar Dossiers/

 

后台运行

nohup tar -czf domain.tar Domain/ &

nohup tar -czf Dossiers.tar Dossiers/ &

 

nohup tar -cf backup.tar Domain/ Dossiers/ logs/ &

 

 

 

名称 : tar (The GNU version of the tar archiving utility)
使用权限 : 所有使用者
使用方式 : tar [-czxf] [NAME] [FILES/DIRECTORIES]
说明 : 可以将多个文件或目录打包成一个文件,也可以将打包文件或压缩文件解包或解压缩。(tar原本只是用来将多个文件打包成一个文件的,不具备压缩功能,是后来加入了压缩功能。)

参数 :
-c 打包,即创建一个新的包文件
-x 解包
-z 压缩或解压缩(-cz同时打包并压缩)
-f  指定包文件的文件名

范例:
tar -cf myfile.tar test1 test2 test/
将文件test1、test2和目录test一起打包成myfile.tar

tar -xf myfile.tar
将myfile.tar解包至当前目录

tar -czf myfile.tar.gz test1 test2 test/
将文件test1、test2和目录test一起打包并压缩成myfile.tar.gz

tar -xzf myfile.tar.gz
将压缩打包文件myfile.tar.gz解压缩并解包到当前目录


名称:gzip/gunzip
(gzip, gunzip, zcat - compress or expand files)
使用权限 : 所有使用者
使用方式 : gzip [-dt...] [ name ...  ]
gunzip [options...] [ name ...  ]
说明 : gzip和bzip2都是将文件压缩,但是不能将多个文件压缩成一个文件,而且压缩好文件之后源文件就被覆盖了。(gzip和bzip2常配合tar使用)

参数 :
-N N为压缩级别,1最差,9最好
-d 解压缩
-t 测试压缩包

范例:
gzip -9 test.txt   将test.txt以最好的压缩率压缩为test.txt.gz(源文件覆盖)
gzip -d test.txt.gz   或者   gunzip test.txt.gz     将test.txt.gz 解压缩(源压缩文件覆盖)


名称:bzip2/bunzip2
(bzip2, bunzip2 - a block-sorting file compressor)
使用权限 : 所有使用者
使用方式 : bzip2 [-dt...] [ name ...  ]
bunzip2 [options...] [ name ...  ]
说明 : 和gzip使用非常相似(gzip和bzip2常配合tar使用)

参数 :

-N N为压缩级别,1最差,9最好
-d 解压缩
-t 测试压缩包
-v 显示信息

范例:
bzip2 test.txt   将test.txt压缩为test.txt.bz2(源文件覆盖)
bzip2 -d test.txt.bz2   或者   bunzip2 test.txt.bz2     将test.txt.bz2 解压缩(源压缩文件覆盖)
bzip2 -vt test.txt.bz2   测试test.txt.bz2并显示测试情况


名称:zip
(package and compress (archive) files)
使用权限 : 所有使用者
使用方式 : zip [-rdnm...] [ name ...  ]
说明:将文件或目录压缩成.zip文件
参数:
-N N为压缩级别,1最差,9最好
-r  递归表示递归压缩子目录下所有文件
-d  删除解压缩文件中的某一个文件
-m 向压缩文件添加文件

范例:
zip -r9 myfile.zip test1 test2 test/
将文件test1、test2和目录test一起以最好的压缩率压缩到myfile.zip

zip -d myfile.zip smart.txt
删除压缩文件中smart.txt文件

zip -m myfile.zip ./rpm_info.txt
向压缩文件中myfile.zip中添加rpm_info.txt文件


名称:unzip(list, test and extract compressed files in a ZIP archive)
使用权限 : 所有使用者
使用方式 : unzip [-ondt...] [ name ...  ]
说明:显示、测试、解压缩.zip文件
参数:
-o 不提示的情况下覆盖文件
-n 不覆盖已经存在的文件
-d DEST指明将文件解压缩到DEST目录下
-t   测试压缩包
范例:
unzip -o -d test/ test.zip
将test.zip解压缩到当前目录下的test文件夹,若遇到同名文件直接覆盖不予提示


名称rar/unrar
(archive files with compression / extract files from rar archives)
使用权限 : 所有使用者
使用方式 : rar [axlt] [name] [ files/directories ...  ]
unrar [xlt] [FILE]
说明:只能压缩和解压缩.rar文件,所有功能基本都可以用rar来完成,所以可以忽略unrar(特别注意rar、7z常用的是选项,而不是参数,所以不需要在前面打"-",多打了"-"会导致错误)
选项:
a 添加文件到.rar压缩包,如果没有这个压缩包则创建
x 以完整的路径解压缩到当前目录
l  列出压缩包内的内容
t  测试压缩包是否可用

范例:
rar a myfile.rar test1 test2 test/
将文件test1、test2和目录test一起以最好的压缩率压缩到myfile.rar

rar x test.rar  或者  unrar x test.rar
解压缩test.rar到当前目录

rar t test.rar  或者  unrar t test.rar
测试test.rar

rar l test.rar  或者  unrar l test.rar
显示test.rar中的文件


名称:7z(A file archiver with highest compression ratio)
使用权限 : 所有使用者
使用方式 : 7z [axlt] [name] [ files/directories ...  ]
说明: 7z和rar很相似,但在解压缩方面7z比其他几个命令都要方便,它可以解压缩以上所有格式的压缩或打包文件。但是不要用7z来压缩其他格式的文件,否则只能用7z解压缩,而别的相应命令解压缩会出现错误(不支持,乱码,文件大小为零等)
选项:
a     添加文件到压缩包
x      解压缩到完全路径
l      查看压缩包的内容
t      测试压缩包
范例:
7z a myfile.7z test1 test2 test/
将文件test1、test2和目录test一起以最好的压缩率压缩到myfile.7z

7z x test.rar
解压缩test.rar到当前目录

7z t test.zip
测试test.zip

7z l test.tar
显示test.tar中的文件

Last modified onSunday, 14 October 2012 04:07

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
Call Stack
#TimeMemoryFunctionLocation
10.0012412792{main}( ).../index.php:0
20.11854271200Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.11854271200Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.502011393560Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.503311417808Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.506011473136Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.507011500104require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.523711896592K2ControllerItem->execute( ).../k2.php:64
90.523711896592K2ControllerItem->display( ).../BaseController.php:710
100.537512541000K2ControllerItem->display( ).../item.php:78
110.537512541000K2ControllerItem->display( ).../controller.php:19
120.543012908056Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.545512928424K2ViewItem->display( ).../ViewController.php:102
140.671715732512K2ViewItem->display( ).../view.html.php:742
150.671715732512K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.675615904816include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
More in this category: « linux find svn subversion centos »

( ! ) Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
Call Stack
#TimeMemoryFunctionLocation
10.0012412792{main}( ).../index.php:0
20.11854271200Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.11854271200Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.502011393560Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.503311417808Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.506011473136Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.507011500104require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.523711896592K2ControllerItem->execute( ).../k2.php:64
90.523711896592K2ControllerItem->display( ).../BaseController.php:710
100.537512541000K2ControllerItem->display( ).../item.php:78
110.537512541000K2ControllerItem->display( ).../controller.php:19
120.543012908056Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.545512928424K2ViewItem->display( ).../ViewController.php:102
140.671715732512K2ViewItem->display( ).../view.html.php:742
150.671715732512K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.675615904816include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
back to top