当前位置:首页 > 操作系统 > Linux

linux运维实战练习-正则表达式


一、linux运维实战练习题及解答

1、显示/etc/passwd文件中以bash结尾的行

 技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100947936.jpg" title="1.png" />

2、显示/etc/passwd文件中的两位数或三位数

   技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100948185.jpg" title="2.jpg" />

3、显示`netstat -tan`命令结果中以‘LISTEN’后跟0个、1个或者多个空白字符结尾的行

   技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100948819.jpg" title="4.jpg" />

4、添加用户bash、testbash、basher以及nologin用户(nologin用户的shell为/sbin/nologin);而后找出/etc/passwd文件中用户名与其shell名相同的行

   技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100949128.jpg" title="1.jpg" />

5、显示当前系统上root、centos或者user1用户的默认shell和UID (请事先创建这些用户,若不存在)

   技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100949439.jpg" title="1.jpg" />

6、找出/etc/rc.d/init.d/functions文件中某单词(单词中间可以存在下划线)后面跟着一组小括号的行

   技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100949841.jpg" title="1.jpg" />

7、使用echo输出一个路径,而后egrep找出其路径基名;进一步的使用egrep取出其目录名

   技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100950332.jpg" title="1.jpg" />


8、找出ifconfig命令执行结果中1-255之间的数字

  技术分享650) this.width=650;" src="/upload/getfiles/default/2022/11/12/20221112100950715.jpg" title="3.jpg" />


本文出自 “小多哥” 博客,请务必保留此出处http://icestick8586.blog.51cto.com/9867871/1690907

原文:http://icestick8586.blog.51cto.com/9867871/1690907


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!