考前必看

修改主机名
hostnamectl set-hostname www.A1.com
echo "www.A1.com" >/etc/hostname
hostname www.A1.com
修改网络
vi /etc/sysconfig/network-scirpts/ifcfg-eth0
DEVICE=eth0 ================》这里是网卡名称第一块网卡为eth0,第二块为eth1...
BOOTPROTO=static============》static为固定IP地址,非动态DHCP获取
BROADCAST=10.0.0.255 =======》这里是广播地址,一般为网络地址的最后一个地址。
HWADDR=00:0C:29:0E:5F:63 ===》这里mac地址,不同的机器不能重复,尤其是在刻隆虚拟机或复制网卡配置时要注意。
IPADDR=10.0.0.161 ==========》这里是IP地址
NETMASK=255.255.255.0=======》子网掩码/24
NETWORK=10.0.0.0   =========》网段设置
ONBOOT=yes =================》开机网卡自启动
GATEWAY=10.0.0.254==========》网关的配置,也可以命令行通过route添加删除。
TYPE=Ethernet===============》类型
查看路由
route -n
netstat -rn
添加默认路由
route add default gw 192.168.0.1
route add -net 0.0.0.0 gw 192.168.0.1
route add -net 0.0.0.0/32 gw 192.168.0.1
route delete default gw 192.168.0.1
添加某一个网段的路由
route add -net 10.1.1.0 netmask 255.255.255.0 gw 192.168.0.1
route delete -net 10.1.1.0/24 gw 192.168.0.1
添加某个主机的路由
route add -host 192.168.0.109 netmask 255.255.255.0 gw 192.168.0.1
为路由指定网络接口
#默认路由不能这样指定
route add -net 10.1.1.0/24 dev ens33

保存到文件中

vi /etc/sysconfig/network-scripts/route-ens33
10.1.1.0/24 via 192.168.0.1
172.10.1.0/24 via 172.10.1.1
安装卸载rpm
vi /etc/yum.conf
# in /etc/yum.repos.d
proxy=http://168.101.58.226:8080
yum install -y lrzsz
rpm -ivh *.rpm
yum groupinstall Security Tools -y

金蝶面试题

#根据nginx 日志查询出访问该网站最大的ip
awk '{count[$1]++} END{for(i in count){print count[i],i}}' log|sort -rn |head
awk '{count[$1]++} END{for(i in count){print count[i],$0}}' log|sort -rn |head
awk '{print $1}' log |sort|uniq -c|sort -rn|head

统计系统tcp 连接状态
netstat -ant|awk '{count[$NF]++} END{for(i in count){print count[i],i }}'
要求把下面文件名中finish.去掉
1.finish.txt
2.finish.txt
3.finish.txt
4.finish.txt
5.finish.txt
6.finish.txt
7.finish.txt
8.finish.txt
9.finish.txt
10.finish.txt

方法一变量的扩展参数

# ${a%finish.txt}  删除结尾的finish.txt 
[root@tencent-sh 1]# for a in `ls`;do \mv $a ${a%finish.txt}txt;done 
[root@tencent-sh 1]# ls
10.txt  1.txt  2.txt  3.txt  4.txt  5.txt  6.txt  7.txt  8.txt  9.txt

方法二先拼接命令后交给bash

ls | awk -F "finish" '{print "mv",$0,$1$2}'|bash -

方法三 rename

# rename 要替换内容 替换后内容 对哪些文件
rename finish. "" *
10.txt  1.txt  2.txt  3.txt  4.txt  5.txt  6.txt  7.txt  8.txt  9.txt

awk执行系统命令

echo ""|awk 'END{system("hostname")}' 
echo ""|awk 'END{print "ls"|"bash"}'

查看systemd 的日志

# -f --follow
# -u --unit  查看指定的systems unit.如果不指定默认查看所有服务的日志
# -S 指定开始时间
# -U 指定结束时间
[root@hdss7-22 ~]# journalctl -f -u network.service   
-- Logs begin at Thu 2019-07-11 11:10:15 CST. --
Mar 03 16:16:11 iZwz90euv4wivardwg6a7rZ systemd[1]: Stopped LSB: Bring up/down networking.
-- Reboot --
Mar 03 16:16:42 iZwz90euv4wivardwg6a7rZ systemd[1]: Starting LSB: Bring up/down networking...
Mar 03 16:16:42 iZwz90euv4wivardwg6a7rZ network[537]: Bringing up loopback interface:  [  OK  ]
Mar 03 16:16:42 iZwz90euv4wivardwg6a7rZ network[537]: Bringing up interface eth0:
Mar 03 16:16:43 iZwz90euv4wivardwg6a7rZ dhclient[724]: DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x6a4bc8b7)
Mar 03 16:16:43 iZwz90euv4wivardwg6a7rZ dhclient[724]: DHCPACK from 172.21.175.253 (xid=0x6a4bc8b7)
Mar 03 16:16:46 iZwz90euv4wivardwg6a7rZ dhclient[724]: bound to 172.21.160.147 -- renewal in 142746767 seconds.
Mar 03 16:16:46 iZwz90euv4wivardwg6a7rZ network[537]: Determining IP information for eth0... done.
Mar 03 16:16:46 iZwz90euv4wivardwg6a7rZ network[537]: [  OK  ]
Mar 03 16:16:46 iZwz90euv4wivardwg6a7rZ systemd[1]: Started LSB: Bring up/down networking.

posted @ 2021-04-08 22:24  mingtian是吧  阅读(48)  评论(0编辑  收藏  举报