1. tar -czf /usr/ms/avatar /usr/ms/userFiles
-c :建立一个压缩文件的参数指令(create 的意思)
-z :是否同时具有 gzip 的属性
-f :使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!
tar: Removing leading `/' from member names
2. tar -czf /usr/ms/avatar -C /usr/ms/userFiles
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
3. tar -czf /usr/ms/avatar.tar -C /usr/ms/userFiles/
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
4. tar -czFf /usr/ms/avatar.tar -C /usr/ms/userFiles/
-F 的意思是指定包含打包文件或目录列表的文件
-f 的意思是指定生成打包文件名
tar: Cannot use multi-volume compressed archives
Try `tar --help' or `tar --usage' for more information.
5. tar -czfF /usr/ms/avatar.tar -C /usr/ms/userFiles
tar: Removing leading `/' from member names
tar: /usr/ms/avatar.tar: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
6. cd /usr/ms
tar -czfF avatar -C /usr/ms/userFiles
-c :建立一个压缩文件的参数指令(create 的意思)
-z :是否同时具有 gzip 的属性
-f :使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!
tar: Removing leading `/' from member names
2. tar -czf /usr/ms/avatar -C /usr/ms/userFiles
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
3. tar -czf /usr/ms/avatar.tar -C /usr/ms/userFiles/
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
4. tar -czFf /usr/ms/avatar.tar -C /usr/ms/userFiles/
-F 的意思是指定包含打包文件或目录列表的文件
-f 的意思是指定生成打包文件名
tar: Cannot use multi-volume compressed archives
Try `tar --help' or `tar --usage' for more information.
5. tar -czfF /usr/ms/avatar.tar -C /usr/ms/userFiles
tar: Removing leading `/' from member names
tar: /usr/ms/avatar.tar: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
6. cd /usr/ms
tar -czfF avatar -C /usr/ms/userFiles
success 因为:执行tar之前cd切换到要打包的目录就可以了
7. 备份目录:
tar -czf /usr/temp/file /usr/file
备份出来的数据包含根目录;
tar -czf /usr/temp/file -C /usr file
备份出来的数据不包含根目录
解压目录:
rm -rf /usr/file (移除旧的目录)
tar -xmzf /usr/temp/file -C /usr