linux运维初级课前随机考试:
一、笔试部分:
1.开机配置服务自启动的文件路径是?
解答:
/etc/rc.local
2.网卡配置文件的路径
解答:
/etc/sysconfig/network-scripts/ifcfg-eth0
3.Client 端DNS文件的路径
解答:
/etc/resolv.conf
提示:服务端DNS默认配置文件路径 /etc/named.conf
4.如何用命令行方式给linux机器添加一个默认网关,假设网关地址为10.0.0.254
解答:
route add default gw 10.0.0.254
5.查找服务器内名字为services的文件.给出命令.
解答:
[root@oldboy ~]# find /etc -name services
/etc/logwatch/conf/services
/etc/services
/etc/avahi/services
6.已知字符串 oldboy caojunbiao chenyanfei guoxing qingyun,linliang
请通过cut命令请取出oldboy和linliang两个字符串
解答:
[root@oldboy ~]# echo "oldboy caojunbiao chenyanfei guoxing qingyun linliang" >oldboy.test
[root@oldboy ~]# cat oldboy.test
oldboy caojunbiao chenyanfei guoxing qingyun linliang
[root@oldboy ~]# cut -d" " -f2,6 oldboy.test
caojunbiao linliang
提示:下面命令是取2-6个字符串
[root@oldboy ~]# cut -d" " -f2-6 oldboy.test
caojunbiao chenyanfei guoxing qingyun linliang
7.查看apache服务的进程
解答:
[root@oldboy ~]# ps -ef|grep httpd|grep -v grep
root 5130 1 0 Jan12 ? 00:00:03 /application/apache2.2.9/bin/httpd -k start
daemon 5131 5130 0 Jan12 ? 00:00:00 /application/apache2.2.9/bin/httpd -k start
daemon 28821 5130 0 May13 ? 00:00:00 /application/apache2.2.9/bin/httpd -k start
daemon 28944 5130 0 08:58 ? 00:00:00 /application/apache2.2.9/bin/httpd -k start
daemon 30985 5130 0 11:08 ? 00:00:00 /application/apache2.2.9/bin/httpd -k start
如果为worker模式:
则:
[root@oldboy ~]# pstree -a|grep httpd|grep -v grep |wc -l
1526
提示:会有很多,加wc -l看看数量吧.
8.已知文件oldboy.txt内容为
oldboy
caojunbiao
chenyanfei
guoxing
qingyun
linliang
请通过sed命令把文件中包含guoxing的字符串替换为oldboy.
解答:
[root@oldboy ~]# cat test.txt
oldboy
caojunbiao
chenyanfei
guoxing
qingyun
linliang
[root@oldboy ~]# sed -i ''s#guoxing#oldboy#'' test.txt
[root@oldboy ~]# cat test.txt
oldboy
caojunbiao
chenyanfei
oldboy
qingyun
linliang
[root@oldboy ~]# sed -i ''s#oldboy#qingyun#'' test.txt
[root@oldboy ~]# cat test.txt
qingyun
caojunbiao
chenyanfei
qingyun
qingyun
linliang
8.请取出服务器eth0网卡配置的ip地址字符串.
如:服务器IP地址为10.0.0.100,则取出结果为10.0.0.100
解答:
[root@oldboy ~]# ifconfig eth0|grep 192
inet addr:192.168.1.250 Bcast:192.168.1.255 Mask:255.255.255.0
[root@oldboy ~]# ifconfig eth0|grep 192|cut -c 21-33 =======>这个方法不常用.
192.168.1.250
[root@oldboy ~]# ifconfig eth0|grep 192|sed ''s#^.*addr:##''|sed ''s#Bcast.*$##''
192.168.1.250
[root@oldboy ~]# ifconfig eth0|grep 192|sed ''s/^.*addr://g'' | sed ''s/Bcast.*$//g''
192.168.1.250
9.实现打包/oldboy目录
解答:
tar zcvf oldboy.tar.gz /oldboy
10.实现打包/oldboy目录(排除/oldboy中的test文件)
tar zcvf oldboy.tar.gz /oldboy --exclude=/oldboy/test
提示:还可 |