一.文件归档
1.
[root@chihao1 ~]# tar cf etc.tar /etc
tar: Removing leading `/' from member names
最后一位是要归档的文件,倒数第二位是归档后起什么名字
2.
[root@chihao1 ~]# tar cf haha.tar /etc/
tar: Removing leading `/' from member names
[root@chihao1 ~]# tar tf haha.tar
etc/
etc/mtab
etc/fstab
etc/crypttab
etc/dnf/
etc/dnf/modules.d/
etc/dnf/modules.d/container-tools.module
etc/dnf/modules.d/llvm-toolset.module
tar -tf
可以查看归档后文件的内容
3.
[root@chihao1 ~]# tar Pcf haha.tar /etc/
如果要保留文件之前的/,在前面加大P
4.
[root@chihao1 ~]# tar cvf x.tar /etc/
c创建,v显示打包过程,指定创建后的名字
5.
[root@chihao1 ~]# ls
Desktop Downloads mnt Pictures Templates Videos
Documents haha.tar Music Public test
[root@chihao1 ~]# tar rf haha.tar test
tar: Removing leading `/' from member names
[root@chihao1 ~]# tar tf haha.tar
/etc/locale.conf
/etc/hostname
/etc/my.cnf
test
tar rf haha.tar test
把test文件放入归档后的文件
[root@chihao1 ~]# tar f haha.tar --get test
[root@chihao1 ~]# ls
Desktop Downloads mnt Pictures Templates Videos
Documents haha.tar Music Public test
tar f haha.tar --get test
单独把归档文件中的test提取出来
7.
[root@chihao1 ~]# tar xf haha.tar
tar: Removing leading `/' from member names
[root@chihao1 ~]# ls
Desktop Downloads haha.tar Music Public test
Documents etc mnt Pictures Templates Videos
tar xf haha.tar
解档
8.tar xf haha.tar -C /mnt
指定解档路径到mnt
二.文件压缩
常见的压缩格式zip gz bz2 xz
du -sh haha.tar
查看大小
1.zip格式
[root@chihao1 ~]# zip -r haha.tar.zip haha.tar
后面为要压缩的文件
[root@chihao1 ~]# unzip haha.tar.zip
解压缩此文件
2.gz格式
[root@chihao1 ~]# gzip haha.tar
压缩
[root@chihao1 ~]# gunzip haha.tar.gz
解压
gz格式这样压缩不会产生新文件
3.bz2格式
[root@chihao1 ~]# bzip2 haha.tar
[root@chihao1 ~]# bunzip2 haha.tar.bz2
压缩和解压
4.xz格式
xz haha.tar
unxz haha.tar.xz
压缩和解压
5.打包和压缩同时进行:
[root@chihao1 mnt]# tar zcf haha.tar.gz /etc/
z对应gz c创建 f指定名称
[root@chihao1 mnt]# tar jcf xixi.tar.bz2 /etc/
j对应bz2
[root@chihao1 mnt]# tar Jcf hehe.tar.xz /etc/
J对应xz
如何解压:
[root@chihao1 mnt]# tar zxf haha.tar.gz
[root@chihao1 mnt]# tar jxf xixi.tar.bz2
[root@chihao1 mnt]# tar Jxf hehe.tar.xz
z-gz
j-bz2
J-xz
三.IP原理
1.ip是由32个01组成
11111110.11111110.11111110.11111110 = 254.254.254.254
8bit=1byte
2.网络位一致,主机位不一致的2个IP可以直接通讯
172.25.254.1/24
24=255.255.255.0
172.25.254.2/24
172.25.0.1/16
3.子网掩码
用来划分网络区域
子网掩码非0的位对应的ip上的数字表示这个ip的网络位
子网掩码0位对应的数字是ip的主机位
网络位表示网络区域
主机位表示网络区域里某台主机
4.图形方式设定IP
[root@chihao1 Desktop]# nm-connection-editor
添加以太网-选好网卡
IPV4-MANUAL
设置完成后
[root@chihao1 Desktop]# nmcli connection reload
[root@chihao1 Desktop]# nmcli connection down enp1s0
Connection 'enp1s0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)
[root@chihao1 Desktop]# nmcli connection up enp1s0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
每一台机子的网卡名是不一样的,所以填自己的网卡就好
5.无图形修改ip
nmtui
记好自己的网卡名,忘记就用ifconfig
查看
[root@chihao1 ~]# ip addr show
也可以用这个命令
6.用ifconfig或ipaddr设定ip
ifconfig device ip/24
ifconfig device down
##关闭
ifconfig device up
##开启
ip addr show 检测
ip addr add ip/24 dev 网卡名 设 定
ip addr del dev 网卡名 ip/24 删 除
设置多个网卡必须用ipaddr
ifconfig在企业7中用不了
7.
ping
ping -c 1
ping -w 1
ping -c1 -w1 ip
##检测网络是否通畅
##ping 1 次
##等待1秒
##ping1次等待1秒
8.配置文件方式管理网络
[root@chihao2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-enp1s0
BOOTPROTP=static|none手动模式
NETMASK和PREFIX写一个就可以
所有网络的设定完成之后都要reload
**这些内容都可以在此查看到
[root@chihao2 ~]# cd /usr/share/doc/initscripts/
[root@chihao2 initscripts]# ls
sysconfig.txt