前言
一、实验环境的设定
需要2台虚拟机,并保证这2台主机可以通信。先要关闭火墙
systemctl disable firewalld
sysctemctl stop firewalld
1 设定主机名
2 id
3 清空.shh文件
二、scp命令
远程的控制文件
scp 本地文件 远程主机的用户@远程主机ip:远程主机目录的绝对路径
#将本地文件传输到远程主机的某一目录中(上传)
scp 远程主机用户@远程主机ip:远程主机文件的绝对路径 本地文件
#将远程主机的文件复制到本地(下载)
实验步骤:
把westosb的文件复制到westosa中
把westosb的目录复制到westosa中
[root@westosa mnt]# scp -r root@172.25.254.214:/mnt/westosdir /mnt
把westosa的文件上传到westosb中 不显示用-p
三、rsync命令
(比scp多个重复检测)
rsync 文件
rsync 远程用户@远程主机IP:远程主机目录
rsync
-r #复制目录
-l #复制链接
-p #复制权限
-t #复制时间戳
-o #复制拥有者
-g #复制拥有组
-D #复制设备文件
实验步骤:
westosb创建文件
复制westosa的内容到westosa
[root@westosa mnt]# rsync -r root@172.25.254.214:/mnt /mnt/
没有/表示把整个目录复制过来
[root@westosa mnt]# rsync -r root@172.25.254.214:/mnt/ /mnt/
有/表示复制目录里面的内容
复制链接过来
[root@westosa mnt]# rsync -lr root@172.25.254.214:/mnt/ /mnt/
复制权限过来
[root@westosa mnt]# rsync -lpr root@172.25.254.214:/mnt/ /mnt/
复制用户过来
[root@westosa mnt]# rsync -lpor root@172.25.254.214:/mnt/ /mnt/
复制拥有组过来
[root@westosa mnt]# rsync -lpogr root@172.25.254.214:/mnt/ /mnt/
复制时间过来
[root@westosa mnt]# rsync -lpogtr root@172.25.254.214:/mnt/ /mnt/
复制设备文件过来
[root@westosa mnt]# rsync -Dr root@172.25.254.214:/dev/pts/ /mnt/
四、tar命令
1、文件归档
2.文件压缩
3.tar +压缩