文件的传输及打包压缩
一.scp
1.文件的上传
scp 本地文件 远程主机用户@远程主机IP:远程主机目录
scp /root/Desktop/clientfile1 [email protected]:/root/Desktop/ ##本地文件clientfile1上传到ip为172.25.254.243里该目录下
scp -r /root/Desktop/clienttest1 [email protected]:/root/Desktop/ ##本地文件clientfile1上传到ip为172.25.254.243里该目录下
下载
scp 远程主机用户@远程主机IP:远程主机目录 本地目录
scp [email protected]:/root/Desktop/serverfile1 . ##ip为172.25.254.243里该目录下文件serverfile1下载到本地
scp -r [email protected]:/root/Desktop/serverfile1 . ##ip为172.25.254.243里该目录下目录servertest1下载到本地
二.rsync
远程同步,速度快,默认的会忽略文件属性,链接文件等
-r ##目录复制
-l ##不忽略链接
-p ##不忽略权限
-t ## 不忽略时间戳
-o ##不忽略用户
-g ##不忽略组
-D ##不忽略块设备
rsync /root/Desktop/clientfile2 [email protected]:/root/Desktop/
三.打包
tar ##归档文件
-c ##新建
-v ##显示过程
-f ##指定归档文件名称
-t ##查看归档文件内容
-r ##添加文档到归档中
--get ##解档指定文件
tar cf etc.tar /etc/ ##将/etc/目录打包到当前目录
- tar tf etc.tar ##列表显示包内文件
- tar rf etc.tar westos ##追加westos文件到包内
- tar f etc.tar –delete westos ##删除包内westos
- tar xf etc.tar ##解压到当前目录下
- tar f etc.tar –get westos ##解压具体文件westos到当前目录
- tar xf etc.tar -C /mnt/ ##解压到指定目录下
四.压缩
zip
zip -r etc.tar.zip etc.tar
unzip etc.tar.zip
gzip
gzip etc.tar
gunzip etc.tar.gz
bzip2
bzip2 etc.tar
5.打包压缩
gzip
tar zcf etc.tar.gz /etc/
tar zxf etc.tar.gz
bzip
tar jcf etc.tar.bz2 /etc/
tar jxf etc.tar.bz2
xz
tar Jcf etc.tar.xz /etc/
tar Jxf etc.tar.xz