scp命令
***scp 本地文件 远程主机用户@远程主机ip:远程主机目录的绝对路径***
scp file1 root@172.25.254.20:/root/Desktop
***scp 远程主机用户@远程主机ip:远程主机文件的绝对路径 本地文件***
scp root@172.25.254.20:/mnt/westos_rhel8 /root/Desktop
rsync命令
rsync -r root@172.25.254.20:/root/Desktop /mnt ##同步目录本身及目录中的文件
rsync -r root@172.25.254.20:/root/Desktop/ /mnt ##只同步目录中的文件
rsync -rl root@172.25.254.20:/root/Desktop/ /mnt ##同步连接
rsync -rlp root@172.25.254.20:/root/Desktop/ /mnt ##同步权限
rsync -rlpog root@172.25.254.20:/root/Desktop/ /mnt ##同步用户组
rsync -rlpogt root@172.25.254.20:/root/Desktop/ /mnt ##同步时间
rsync -rD root@172.25.254.20:/dev/pts /mnt ##同步设备文件
rsync和scp命令的对比
rsync命令在文件传输中所需要的时间远小于scp命令的时间。
原因:
实验如下:
文件归档及压缩
文件归档——tar命令
tar
tar c ##创建
tar f ##指定文件名称
tar x ##解档
tar v ##显示过程
tar t ##查看
tar r ##向归档文件中添加文件
tar --get ##解档指定文件
tar --delete ##删除指定文件
tar -C ##指定解档路径
文件压缩——zip/gzip/bzip/xz命令
***zip***
zip -r mnt.tar.zip mnt.tar ##zip格式压缩
unzip mnt.tar.zip ##zip格式解压
***gzip***
gzip mnt.tar ##gzip格式压缩
gunzip mnt.tar.gz ##gzip格式解压
***bzip***
bzip2 mnt.tar ##bzip2格式压缩
bunzip2 etc.tar.bz2 ##bzip2格式解压
***xz***
xz mnt.tar ##xz格式压缩
unxz mnt.tar.xz ##xz格式解压
tar+压缩——gz/bz/xz格式
***gzip***
tar zcf etc.tar.gz /etc
tar zxf etc.tar.gz
***bzip2***
tar jcf etc.tar.ba2 /etc
tar jxf etc.tar.ba2
***xz***
tar Jcf etc.tar.xz /etc
tar Jxf etc.tar.xz
ending......