文件與文件系統的壓縮與打包

壓縮文件的用途與技術

Linux系統常見的壓縮命令

  Compress

  gzip,zcat

  bzip2,bzcat

打包命令:tar


配置本地yum源

mount /dev/cdrom /mnt


/etc/yum.repos.d/aaa.repo

[aaa]

name=localyum

baseurl=file:///mnt

enabled=1

gpgcheck=0


yum list ncopmress

yum install ncompress -y



cd /opt

cp /etc/services .

compress -v services

uncompress


compress -c -v services > services.Z

rm -rf *



cp /etc/hosts .

gzip hosts

zcat hosts.gz


gzip -d hosts.gz 解壓


gzip -c hosts > hosts.gz


bzip2 hosts


bzip2 -d hosts.bz2


bzip2 -c hosts > hosts.bz2


bzcat  hosts.bz2


rm -rf hosts.bz2


zip hosts.zip hosts    zip壓縮

unzip hosts.zip


打包命令:tar

tar cvf hosts.tar hosts

源文件保留


tar cvf hosts.tar hosts --remove-files 不保留源文件


tar tvf hosts.tar 不解壓查看歸檔內容


tar xvf hosts.tar


tar xvf hosts.tar -C  aa/ 解壓到指定目錄


cp /etc/services /etc/passwd /etc/hosts .

tar cvf xx.tar * --remove-files

tar xvf  xx.tar hosts


tar調用gzip or bzip2

tar zcvf xx.tar *    

tar zxvf xx.tar.gz

rm -rf xx.tar.gz


tar jcvf xx.tar.bz2 * --remove-files

tar jxvf xx.tar.bz2 解壓縮


tar jxvf xx.tar.bz2 hosts 只解壓hosts


完整備份工具: dump


完全備份 0

增量備份

差異備份


dump -0




光盤寫入工具:

dd if=/dev/zero of=file1 bs=1M count=1

創建3個文件

mkisofs -o xx.iso file1 file2 file3



cp /dev/cdrom xxx.iso

mount -o  loop xxx.iso /mnt


其他常見的壓縮與備份工具


dd if=/dev/sda3 of=test



拷貝file1,4到/opt


find -name 'file*' |cpio -o > xx.cpio  -o打包

cpio -iu < xx.cipo  解壓檔 -i解包


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章