需要两台主机并且保证这两台主机是可以通信的
scp 本地文件 远程主机用户@远程主机 ip:远程主机目录的绝对路径
scp 远程主机用户@远程主机 ip:远程主机文件的绝对路径 本地文件
a)把本地文件复制到远程主机 (上传)
scp westos [email protected]:/root/Desktop
scp -r westosdir [email protected]:/root/Desktop ## -r 表示复制目录
scp -q westos [email protected]:/root/Desktop ## -q 传输文件时不显示
进度
b)把远程文件复制到本地(下载)
scp [email protected]:/root/Desktop/westos_rhel8 /root/Desktop
a) rsync 和 scp 命令的对比:
vim check_rsync.sh ##检测 rsync 的传输时间
time rsync -raCq /root/Desktop [email protected]:/root/Desktop
time rsync -raCq /root/Desktop [email protected]:/root/Desktop
time rsync -raCq /root/Desktop [email protected]:/root/Desktop
-r | 复制目录 |
---|---|
-l | 复制链接 |
-p | 复制权限 |
– | – |
t | 复制时间戳 |
o | 复制拥有者 |
– | – |
g | 复制拥有组 |
D | 复制设备文件 |
**执行命令看效果:
rsync -r [email protected]:/root/Desktop /mnt ##同步目录本身其目录中的文件
rsync -r [email protected]:/root/Desktop/ /mnt ##只同步目录中的文件
rsync -rl [email protected]:/root/Desktop/ /mnt ##同步链接
rsync -rlp [email protected]:/root/Desktop/ /mnt ##同步权限
rsync -rlpog [email protected]:/root/Desktop/ /mnt ##同步用户组
rsync -rlpogt [email protected]:/root/Desktop/ /mnt ##同步时间
rsync -rD [email protected]:/dev/pts /mnt ##同步设备文件**
tar rf etc.tar westosfile
解档
tar f etc.tar --get westosfile
tar f etc.tar --delete westosfile
删除文件:
文件的压缩
zip -r mnt.tar.zip mnt.tar | #zip 格式压缩 |
---|---|
unzip mnt.tar.zip | #zip 格式解压缩 |
gzip mnt.tar | #gzip 格式压缩 |
– | – |
gunzip mnt.tar.gz | gzip 格式解压缩 |
bzip2 mnt.tar | #bzip2 格式压缩 |
– | – |
bunzip2 etc.tar.bz2 | #bzip2 格式解压缩 |
xz mnt.tar | #xz 格式压缩 |
– | – |
unxz mnt.tar.xz | #xz 格式解压缩 |
zip格式压缩
解压
xz格式压缩
解压
**3.tar+压缩
gzip
tar zcf etc.tar.gz /etc
tar zxf etc.tar.gz
bzip2
tar jcf etc.tar.bz2 /etc
tar jxf etc.tar.bz2