您的位置:首页 > 运维架构 > Linux

linux运维命令综合考试及参考答案20110605

2012-12-14 12:15 537 查看
linux运维初级班课前综合考试及参考答案20110605

#########################################################

#《老男孩linux就业培训中心-初级班第七期课前考试及课上讲解

#LINUX命令实战抽查考试

#date:2011-06-05

#出题人:老男孩

#QQ:31333741 MAIL:oldboy521@hotmail.com

#blog: http://oldboy.blog.51cto.com

#psite: http://oldboy.cc(即将开放)

##########################################################

650) this.width=650;" alt="" src="http://img1.51cto.com/attachment/201106/213311348.jpg" border="0" />

过程命令:

[root@http-server tmp]# cat ett.txt |tr "\n" "+"

1+2+3+4+5+6+7+8+9+10+[root@http-server tmp]# cat ett.txt |tr "\n" "+"|sed 's/\+$/\n/'

1+2+3+4+5+6+7+8+9+10

[root@http-server tmp]# cat ett.txt |tr "\n" "+"|sed 's/\+$/\n/'

1+2+3+4+5+6+7+8+9+10

[root@http-server tmp]# cat ett.txt |tr "\n" "+"|sed 's/\+$/=\n/'

1+2+3+4+5+6+7+8+9+10=

[root@http-server tmp]# cat ett.txt |tr "\n" "+"|sed 's/\+$/=\n/'|bc

(standard_in) 1: parse error

[root@http-server tmp]# cat ett.txt |tr "\n" "+"|sed 's/\+$/\n/'|bc

55

问题2:请获取www.baidu.com 的头(header)信息(考察curl命令)

1.即需要得到如下结果: 请给出命令。

HTTP/1.1 200 OK

Date: Sat, 04 Jun 2011 06:22:39 GMT

Server: BWS/1.0

Content-Length: 7492

Content-Type: text/html;charset=gb2312

Cache-Control: private

Expires: Sat, 04 Jun 2011 06:22:39 GMT

Set-Cookie: BAIDUID=80F597135ACBA8EF3B4B6F02EEE99C0D:FG=1; expires=Sat, 04-Jun-41 06:22:39 GMT; path=/; domain=.baidu.com

P3P: CP=" OTI DSP COR IVA OUR IND COM "

Connection: Keep-Alive

解答:

[root@http-server tmp]# curl -I www.baidu.com

HTTP/1.1 200 OK

Date: Sat, 04 Jun 2011 07:08:22 GMT

Server: BWS/1.0

Content-Length: 7492

Content-Type: text/html;charset=gb2312

Cache-Control: private

Expires: Sat, 04 Jun 2011 07:08:22 GMT

Set-Cookie: BAIDUID=17CDDACA35B51E142D1DA796972BEF3B:FG=1; expires=Sat, 04-Jun-41 07:08:22 GMT; path=/; domain=.baidu.com

P3P: CP=" OTI DSP COR IVA OUR IND COM "

Connection: Keep-Alive

[root@http-server tmp]# curl -I http://www.baidu.com

HTTP/1.1 200 OK

Date: Sat, 04 Jun 2011 07:08:30 GMT

Server: BWS/1.0

Content-Length: 7492

Content-Type: text/html;charset=gb2312

Cache-Control: private

Expires: Sat, 04 Jun 2011 07:08:30 GMT

Set-Cookie: BAIDUID=899D297BCA6475E94BE17E829B6D46BA:FG=1; expires=Sat, 04-Jun-41 07:08:30 GMT; path=/; domain=.baidu.com

P3P: CP=" OTI DSP COR IVA OUR IND COM "

Connection: Keep-Alive

2.请用一条命令 取得 字符串 HTTP/1.1 200 OK 请给出命令(这个是难点)。

解答:

[root@http-server tmp]# curl -I http://www.baidu.com|head -1

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

0 7492 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

HTTP/1.1 200 OK

[root@http-server tmp]# curl -I http://www.baidu.com|grep 200

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

curl: (52) Empty reply from server

[root@http-server tmp]# curl -I -s http://www.baidu.com|head -1

HTTP/1.1 200 OK

问题3:一个目录ett下 有3个文件 a,b,c

请打包整个ett目录,但是要排除C文件,即不打包c文件。(考察tar命令)

解答:见单独的tar排除打包总结

tar排除打包总结(19:54 2009-3-19)

man tar:

--exclude PATTERN

exclude files based upon PATTERN

-X, --exclude-from FILE

exclude files listed in FILE

测试准备:

cd /

mkdir -p /test/baoliu

mkdir -p /test/paichu

touch exceptlist;echo "paichu">exceptlist

测试开始:

1、--exclude参数

cd /

tar zcvf paichu.tar.gz ./test --exclude=test/paichu

./test/

./test/baoliu/

2、X 或--exclude-from参数

cd /

[root@oldboy /]# cat exceptlist

paichu

[root@oldboy /]# tar zcvfX paichuX.tar.gz /exceptlist ./test

./test/

./test/baoliu/

tar zcvf oldboy51-100916.tar.gz ./oldboy --exclude=oldboy/logs
本文出自 “老男孩的linux博客” 博客,请务必保留此出处http://oldboy.blog.51cto.com/2561410/584503
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: