一、归档和压缩
归档:archive
tar命令归档的常用选项:
[root@linuxidc ~]# tar --helpExamples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely. 列出归档文件中的文件
tar -xf archive.tar # Extract all files from archive.tar.
Main operation mode:
-A, --catenate, --concatenate append tar files to an archive 追加文件到一个归档文件
-c, --create create a new archive 创建一个归档文件
-r, --append append files to the end of an archive 将文件追加到归档文件的结尾
-t, --list list the contents of an archive 列出归档文件的内容
-u, --update only append files newer than copy in archive 只归档比归档文件更新的文件
-x, --extract, --get extract files from an archive 解压归档文件
-C, --directory=DIR change to directory DIR 制定归档或解归档的路径
--remove-files remove files after adding them to the archive 归档完成之后删除原文件
压缩:compress
tar命令压缩的常用选项:
Compression options:
filter through PROG (must accept -d)
-j, --bzip2 filter the archive through bzip2
-J, --xz filter the archive through xz
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
-Z, --compress, --uncompress filter the archive through compress
[root@linuxidc tmp]# tar jcvf aa.bz2 aa
[root@linuxidc tmp]# tar zcvf aa.gz aa
[root@linuxidc tmp]# tar jxvf aa.bz2 /opt/
[root@linuxidc tmp]# tar zxvf aa.gz /opt/
cpio命令归档压缩rpm安装文件
cpio的常用选项:
[root@linuxidc tmp]# cpio --help
Examples:
# Copy files named in name-list to the archive
cpio -o < name-list [> archive]
# Extract files from the archive
cpio -i [< archive]
# Copy files named in name-list to destination-directory
cpio -p destination-directory < name-list
Main operation mode:
-i, --extract Extract files from an archive (run in copy-in
mode)
-o, --create Create the archive (run in copy-out mode)
-p, --pass-through Run in copy-pass mode
-t, --list Print a table of contents of the input
rpm安装包的本质是一个压缩包,安装rpm包相当于将压缩的文件解压缩到对应的文件夹:
[root@linuxidc xx]# rpm2cpio ../vsftpd-3.0.2-9.el7.x86_64.rpm |cpio -id
707 blocks
[root@linuxidc xx]# ls
etc usr var xx1 xx2
2015职称计算机考试书PowerPoint2007中 .. 定价:¥45 优惠价:¥42 更多书籍 | |
2015年全国职称计算机考试教材(2007模 .. 定价:¥225 优惠价:¥213 更多书籍 |