1.文件归档
文件归档,就是把多个文件变成一个归档文件
2.tar命令
tar c ##创建
[root@localhost ~]# tar cf /mnt/etc.tar /etc/
tar: Removing leading `/' from member names
[root@localhost ~]# ls /mnt/
etc.tar file
f ##指定归档文件名称
t ##显示归档文件中的内容
[root@localhost ~]# tar ft /mnt/etc.tar
etc/
etc/fstab
etc/crypttab
etc/mtab
etc/pki/
etc/pki/rpm-gpg/
etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta
etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-former
etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-release
etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-rhx
etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
etc/pki/ca-trust/
etc/pki/ca-trust/README
etc/pki/ca-trust/extracted/
etc/pki/ca-trust/extracted/README
etc/pki/ca-trust/extracted/java/
etc/pki/ca-trust/extracted/java/README
etc/pki/ca-trust/extracted/java/cacerts
etc/pki/ca-trust/extracted/openssl/
etc/pki/ca-trust/extracted/openssl/README
etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
etc/pki/ca-trust/extracted/pem/
etc/pki/ca-trust/extracted/pem/README
etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem
etc/pki/ca-trust/source/
etc/pki/ca-trust/source/README
etc/pki/ca-trust/source/anchors/
etc/pki/ca-trust/source/blacklist/
etc/pki/java/
etc/pki/java/cacerts
etc/pki/tls/
etc/pki/tls/cert.pem
etc/pki/tls/certs/
etc/pki/tls/certs/ca-bundle.crt
etc/pki/tls/certs/ca-bundle.trust.crt
etc/pki/tls/certs/Makefile
etc/pki/tls/certs/make-dummy-cert
etc/pki/tls/certs/renew-dummy-cert
etc/pki/tls/misc/
etc/pki/tls/misc/CA
etc/pki/tls/misc/c_hash
etc/pki/tls/misc/c_info
etc/pki/tls/misc/c_issuer
etc/pki/tls/misc/c_name
etc/pki/tls/openssl.cnf
etc/pki/tls/private/
etc/pki/nssdb/
r ##向归档文件中添加文件
--get ##取出单个文件
--delete ##删除单个文件
x ##取出归档文件中的所有内容
-C ##指定解档目录
-z ##gz格式压缩
-j ##bz2格式压缩
-J ##xz格式压缩
2.压缩
gz
gzip etc.tar ##压缩成gz格式
gunzip etc.tar.gz ##解压gz格式压缩包
tar zcf etc.tar.gz /etc ##把文件归档为tar并压缩成gz
tar zxf etc.tar.gz ##解压并解档gz格式压缩包
bz2
bzip2 etc.tar ##压缩成bz2格式
bunzip2 etc.tar.bz2 ##解压bz2格式压缩包
tar jcf etc.tar.bz2 /etc ##把文件归档为tar并压缩成bz2
tar jxf etc.tar.bz2 ##解压并解档bz2格式压缩包
xz
xz etc.tar ##压缩成xz格式
unxz etc.tar.xz ##解压xz格式压缩包
tar Jcf etc.tar.xz /etc ##把文件归档为tar并压缩成zx
tar Jxf etc.tar.xz ##解压并解档xz格式压缩包
zip
zip -r etc.tar.zip etc.tar ##压缩成zip格式
unzip etc.tar.zip ##解压zip格式压缩包
3.系统中的文件传输
scp file username@ip:/dir ##上传
scp username@ip:/dir/file /dir ##下载
[root@localhost ~]# scp * [email protected]:/mnt/
The authenticity of host '172.25.254.165 (172.25.254.165)' can't be established.
ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.25.254.165' (ECDSA) to the list of known hosts.
[email protected]'s password:
anaconda-ks.cfg 100% 8619 8.4KB/s 00:00
Desktop: not a regular file
Documents: not a regular file
Downloads: not a regular file
file 100% 0 0.0KB/s 00:00
Music: not a regular file
Pictures: not a regular file
Public: not a regular file
redhat 100% 1766 1.7KB/s 00:00
redhat.pub 100% 396 0.4KB/s 00:00
Templates: not a regular file
Videos: not a regular file
westos: not a regular file
rsync [参数] file username@ip:/dir
rsync -r ##同步目录
-l ##不忽略链接
-p ##不忽略文件权限
-t ##不忽文件时间戳
-g ##不忽文件所有组
-o ##不忽文件所有人
-D ##不忽略设备文件
[root@localhost ~]# touch game{1..5}
[root@localhost ~]# chown student.student *
[root@localhost ~]# chmod 777 *
[root@localhost ~]# rsync -r * root @172.25.254.165:/mnt
@172.25.254.165's password:
Permission denied, please try again.
@172.25.254.165's password:
Permission denied, please try again.
@172.25.254.165's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]