运维主要工作内容?
取出网卡ip地址 三种方法
取出/etc/fstab 权限
找出/etc下第一层目录中以.conf 结尾的文件复制到/tmp 三种方法
写出Linux启动流程
下面特殊符号及含义 至少写出两种含义
. ! $
单引号 双引号 不加引号区别
运维主要工作内容?
核心三个:
1.数据不丢失
2.网站7*24运行
3.提升用户体验
实际具体职责:
监控:
1.查看网站监控 网站状态 网站流量(带宽)
2.根据监控提示(邮件 微信 电话)进行处理
备份:
3.备份的内容(配置 数据 脚本 网站程序代码) 和检查备份是否能用
代码更新:(代码上线)
4.进行代码上线(运维),代码回滚(老大)
其他项目:
5.根据需求做项目(备份 优化 监控)
6.额外要求及自我学习
mkdir -p /server/files/
cat >>/server/files/reg.txt<<EOF
Zhang Dandan 41117397 :250:100:175
Zhang Xiaoyu 390320151 :155:90:201
Meng Feixue 80042789 :250:60:50
Wu Waiwai 70271111 :250:80:75
Liu Bingbing 41117483 :250:100:175
Wang Xiaoai 3515064655 :50:95:135
Zi Gege 1986787350 :250:168:200
Li Youjiu 918391635 :175:75:300
Lao Nanhai 918391635 :250:100:175
EOF
[root@oldboyedu59 /oldboy]# grep 'oldb.y' oldboy.txt
I am oldboy teacher!
my blog is http://oldboy.blog.51cto.com
our size is http://blog.oldboyedu.com
my god,i am not oldbey,but OLDBOY!
oldboy oldboy oldboy
[root@oldboyedu59 /oldboy]# sed -n '/oldb.y/p' oldboy.txt
I am oldboy teacher!
my blog is http://oldboy.blog.51cto.com
our size is http://blog.oldboyedu.com
my god,i am not oldbey,but OLDBOY!
oldboy oldboy oldboy
[root@oldboyedu59 /oldboy]# awk '/oldb.y/' oldboy.txt
I am oldboy teacher!
my blog is http://oldboy.blog.51cto.com
our size is http://blog.oldboyedu.com
my god,i am not oldbey,but OLDBOY!
oldboy oldboy oldboy
[root@oldboyedu59 /oldboy]# cat /server/files/reg.txt
Zhang Dandan 41117397 :250:100:175
Zhang Xiaoyu 390320151 :155:90:201
Meng Feixue 80042789 :250:60:50
Wu Waiwai 70271111 :250:80:75
Liu Bingbing 41117483 :250:100:175
Wang Xiaoai 3515064655 :50:95:135
Zi Gege 1986787350 :250:168:200
Li Youjiu 918391635 :175:75:300
Lao Nanhai 918391635 :250:100:175
[root@oldboyedu59 /oldboy]# awk '$2~/i$/' /server/files/reg.txt
Wu Waiwai 70271111 :250:80:75
Wang Xiaoai 3515064655 :50:95:135
Lao Nanhai 918391635 :250:100:175
[root@oldboyedu59 /oldboy]# awk '$2~/i$/{print $1,$2,$3}' /server/files/reg.txt
Wu Waiwai 70271111
Wang Xiaoai 3515064655
Lao Nanhai 918391635
第一列是姓氏
第二列是名字
第一第二列合起来就是姓名
第三列是对应的ID号码
最后三列是三次捐款数量
示例:
#显示Xiaoyu的姓氏和ID号码
#条件:显示Xiaoyu
#{动作}: 显示姓氏和id
[root@oldboyedu59 /oldboy]# awk '$2~/Xiaoyu/' /server/files/reg.txt
Zhang Xiaoyu 390320151 :155:90:201
[root@oldboyedu59 /oldboy]#
[root@oldboyedu59 /oldboy]# awk '$2~/Xiaoyu/{print $1,$3}' /server/files/reg.txt
Zhang 390320151
姓氏是Zhang的人,显示他的第二次捐款金额及她的名字
显示所有ID号码最后一位数字是1或5的人的全名
显示所有人的全名,以姓,名的格式显示,如Meng,Feixue
显示Xiaoyu的捐款.每个值时都有以$开头.如$520$200$135
#姓氏是Zhang的人,显示他的第二次捐款金额及她的名字
#条件: 找出包含Zhang的行
#{动作}: 显示捐款的金额和名字
[root@oldboyedu59 /oldboy]# awk '$1~/^Zhang/' /server/files/reg.txt
Zhang Dandan 41117397 :250:100:175
Zhang Xiaoyu 390320151 :155:90:201
[root@oldboyedu59 /oldboy]# awk '/^Zhang/' /server/files/reg.txt
Zhang Dandan 41117397 :250:100:175
Zhang Xiaoyu 390320151 :155:90:201
'$1~/^Zhang/' 第1列中以Zhang开头的
'/^Zhang/' 这一行中以Zhang开头
[root@oldboyedu59 /oldboy]# awk -F"[ :]+" '$1~/^Zhang/{print $1,$2,$5}' /server/files/reg.txt
Zhang Dandan 100
Zhang Xiaoyu 90
[root@oldboyedu59 /oldboy]# awk -F"[ :]+" '$1~/^Zhang/{print $1,$2,$(NF-1)}' /server/files/reg.txt
Zhang Dandan 100
Zhang Xiaoyu 90
#显示所有ID号码最后一位数字是1或5的人的全名
[root@oldboyedu59 /oldboy]# awk '$3~/[15]$/' /server/files/reg.txt
Zhang Xiaoyu 390320151 :155:90:201
Wu Waiwai 70271111 :250:80:75
Wang Xiaoai 3515064655 :50:95:135
Li Youjiu 918391635 :175:75:300
Lao Nanhai 918391635 :250:100:175
[root@oldboyedu59 /oldboy]# awk '$3~/[15]$/{print $1,$2}' /server/files/reg.txt
Zhang Xiaoyu
Wu Waiwai
Wang Xiaoai
Li Youjiu
Lao Nanhai
显示所有人的全名,以姓,名的格式显示,如Meng,Feixue
[root@oldboyedu59 /oldboy]# awk '{print $1","$2}' /server/files/reg.txt
Zhang,Dandan
Zhang,Xiaoyu
Meng,Feixue
Wu,Waiwai
Liu,Bingbing
Wang,Xiaoai
Zi,Gege
Li,Youjiu
Lao,Nanhai
[root@oldboyedu59 /oldboy]# awk '{print $NF}' /server/files/reg.txt|tr ':' '$'
$250$100$175
$155$90$201
$250$60$50
$250$80$75
$250$100$175
$50$95$135
$250$168$200
$175$75$300
$250$100$175
sed 's#:#$#g' reg.txt
s==sub
gsub(/:/,"$")
gsub(/找谁/,"替换成什么")
gsub(/找谁/,"替换成什么",某一列)
[root@oldboyedu59 /oldboy]# awk '{gsub(/:/,"$")}' /server/files/reg.txt
[root@oldboyedu59 /oldboy]# awk '{gsub(/:/,"$"); print $0 }' /server/files/reg.txt
Zhang Dandan 41117397 $250$100$175
Zhang Xiaoyu 390320151 $155$90$201
Meng Feixue 80042789 $250$60$50
Wu Waiwai 70271111 $250$80$75
Liu Bingbing 41117483 $250$100$175
Wang Xiaoai 3515064655 $50$95$135
Zi Gege 1986787350 $250$168$200
Li Youjiu 918391635 $175$75$300
Lao Nanhai 918391635 $250$100$175
[root@oldboyedu59 /oldboy]# awk '{gsub(/:/,"$",$NF); print $4 }' /server/files/reg.txt
$250$100$175
$155$90$201
$250$60$50
$250$80$75
$250$100$175
$50$95$135
$250$168$200
$175$75$300
$250$100$175
创建环境:
head /etc/passwd >/oldboy/passwd.txt
调换/oldboy/passwd.txt文件的第1列和最后一列的位置(不用修改文件内容)
文件内容:
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
想要结果:
/bin/bash:x:0:0:root:/root:root
/sbin/nologin:x:1:1:bin:/bin:bin
sed
[root@oldboyedu59 /oldboy]# sed -r 's#(^.*)(:x.*:)(.*$)#3#g' passwd.txt
[root@oldboyedu59 /oldboy]# sed -r 's#(^.*)(:x.*:)(.*$)#321#g' passwd.txt
awk
[root@oldboyedu59 /oldboy]# awk -F: '{print $7":"$2":"$3":"$4":"$5":"$6":"$1}' passwd.txt
/bin/bash:x:0:0:root:/root:root
/sbin/nologin:x:1:1:bin:/bin:bin
/sbin/nologin:x:2:2:daemon:/sbin:daemon
/sbin/nologin:x:3:4:adm:/var/adm:adm
/sbin/nologin:x:4:7:lp:/var/spool/lpd:lp
/bin/sync:x:5:0:sync:/sbin:sync
/sbin/shutdown:x:6:0:shutdown:/sbin:shutdown
/sbin/halt:x:7:0:halt:/sbin:halt
/sbin/nologin:x:8:12:mail:/var/spool/mail:mail
/sbin/nologin:x:11:0:operator:/root:operator
awk 手里有两杯饮料
awk -F: '{tmp=$1;$1=$NF;$NF=tmp;print $0 }' passwd.txt
awk-调换 /etc/passwd第1列和最后一列的内容-说明
https://www.processon.com/view/link/5aa1df8ae4b0b089b9e60cbd
# OFS awk在显示每一列的时候 每一列之间通过什么分割
# OFS的内容就是 ,的内容
# Output Field Separator 输出分隔符
[root@oldboyedu59 /oldboy]# awk -F: -vOFS=":" '{tmp=$1;$1=$NF;$NF=tmp;print $0 }' passwd.txt
/bin/bash:x:0:0:root:/root:root
/sbin/nologin:x:1:1:bin:/bin:bin
/sbin/nologin:x:2:2:daemon:/sbin:daemon
/sbin/nologin:x:3:4:adm:/var/adm:adm
/sbin/nologin:x:4:7:lp:/var/spool/lpd:lp
/bin/sync:x:5:0:sync:/sbin:sync
/sbin/shutdown:x:6:0:shutdown:/sbin:shutdown
/sbin/halt:x:7:0:halt:/sbin:halt
/sbin/nologin:x:8:12:mail:/var/spool/mail:mail
/sbin/nologin:x:11:0:operator:/root:operator
[root@oldboyedu59 /oldboy]# awk 'BEGIN{print 1/3,2*4,2*2*2*2*2,2^10}'
0.333333 8 32 1024
root@oldboyedu59 /oldboy]# cat /oldboy/oldboy.txt
I am oldboy teacher!
I teach linux.
I like badminton ball,billiard ball and chinese chess!
my blog is http://oldboy.blog.51cto.com
our size is http://blog.oldboyedu.com
my qq is 1351441522
not 4900000448
my god,i am not oldbey,but OLDBOY!
oldboy oldboy oldboy
统计文件中空行的数量
方法1
[root@oldboyedu59 /oldboy]# wc -l /oldboy/oldboy.txt
11 /oldboy/oldboy.txt
方法2
[root@oldboyedu59 /oldboy]# awk '/^$/{i=i+1;print i}' /oldboy/oldboy.txt
1
2
[root@oldboyedu59 /oldboy]# awk '/^$/{i=i+1;print i}' /etc/services
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@oldboyedu59 /oldboy]# awk '/^$/{i=i+1}END{print i}' /etc/services
17
统计access.log中 第9列是200的数量
[root@oldboyedu59 /oldboy]# #统计access.log中 第9列是200的数量
[root@oldboyedu59 /oldboy]#
[root@oldboyedu59 /oldboy]#
[root@oldboyedu59 /oldboy]#
[root@oldboyedu59 /oldboy]# awk '$9==200{i++}END{print i}' access.log
142666
[root@oldboyedu59 /oldboy]# awk '$9~/^200$/{i++}END{print i}' access.log
142666
1+...+10
i i=i+$1 i
1 空 i=0+1 1
2 1 i=1+2 3
3 3 i=3+3 6
4 6 i=6+4 10
[root@oldboyedu59 /oldboy]# seq 10 |awk '{i=i+$1;print i}'
1
3
6
10
15
21
28
36
45
55
[面试题]老男孩教育-三剑客笔试题集合
https://www.jianshu.com/p/61d8883719ac
【文章目录干货】李导简书所有文章分类及连接
https://www.jianshu.com/p/c5e6724f4c3d