打包文件

在Linux下使用光盘(ISO)和压缩文件来打包文件

取消目录所有权限

chmod -R 777 /tmp/etc

一、ISO文件

mkisofs -r -o etc.iso /tmp/etc

二、压缩文件

1. zip

zip -r etc.zip /tmp/etc

2. tar

仅打包,不压缩!

tar -cvf /tmp/etc.tar /etc
  • transform
--transform s/OLD_NAME/NEW_NAME/

gz

tar -zcvf /tmp/etc.tar.gz /etc

transform:

tar -zcvf /tmp/etc.tar.gz /etc --transform s/etc/myetc/

bz2

tar -jcvf /tmp/etc.tar.bz2 /etc

transform:

tar -jcvf /tmp/etc.tar.bz2 /etc --transform s/etc/myetc/

FAQ

This does not look like a tar archive

#gzip -d xxxx.tar.gz
#tar -xf xxxx.tar

gzip: stdin: not in gzip format

$ tar xvf xxxx.tar.gz

参考文章

c – Creates a new .tar archive file.
v – Verbosely show the .tar file progress.
f – File name type of the archive file.
  1. To create a compressed gzip archive file we use the option as z.
  2. To create highly compressed tar file we use option as j.