博客作业网络班22期+第5周(9.5-9.11)

1、显示当前系统上root、fedora或user1用户的默认shell

[root@MyCloudServer wjb]# egrep '^(root|fedora|user1)\>' /etc/passwd | cut -d: -f7
/bin/bash

2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一级小括号的行,形如:hello()

[root@MyCloudServer ~]# grep '\<[[:alpah:]]\+()' /etc/rc.d/init.d/functions

3、使用echo命令输出一个绝对路径,使用grep取出其基名,扩展:取出其路径名

[root@MyCloudServer ~]# echo "/etc/passwd" | egrep -o "[^/]+/?$"
passwd

[root@MyCloudServer ~]# echo "/etc/passwd" | egrep -o ".*/"
/etc/
4、找出ifconfig命令结果中的1-255之间数字

[root@MyCloudServer ~]# ifconfig | egrep -o '\<[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-5][0-5]\>'
4
21
122
10
5、挑战题:写一个模式,能匹配合理的IP地址

[root@MyCloudServer ~]# ifconfig | egrep -o '[1-9]{3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
122.10.117.47
122.10.117.127
255.255.255.128
127.0.0.1
255.0.0.0
6、挑战题:写一个模式,能匹配出所有的邮件地址

[root@MyCloudServer ~]# /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i

7、查找/var目录下属主为root,且属组为mail的所有文件或目录

[root@MyCloudServer ~]# find /var/ -user root -group mail
/var/spool/mail
8、查找当前系统上没有属主或属组的文件,进一步:查找当前系统上没有属主或属级,且最近3天内曾被访问过的文件或目录

[root@MyCloudServer ~]# find / -nouser -a -nogroup

[root@MyCloudServer ~]# find / -nouser -a -nogroup -mtime -3

9、查找/etc目录下所有用户都有写权限的文件

[root@MyCloudServer ~]# find /etc -perm -222 -ls
132257    0 lrwxrwxrwx   1 root     root           15 Apr 30  2013 /etc/rc.sysinit -> rc.d/rc.sysinit
132258    0 lrwxrwxrwx   1 root     root           10 Apr 30  2013 /etc/rc0.d -> rc.d/rc0.d
132272    0 lrwxrwxrwx   1 root     root           11 Apr 30  2013 /etc/sysconfig/network-scripts/ifdown-isdn -> ifdown-ippp
132267
   0 lrwxrwxrwx   1 root     root           20 Apr 30  2013
/etc/sysconfig/network-scripts/ifdown -> ../../../sbin/ifdown
…..

10、查找/etc目录下大于1M,且类型为变通文件的所有文件

[root@MyCloudServer ~]# find /etc/ -type f -a -size +1M
/etc/selinux/targeted/policy/policy.24
/etc/selinux/targeted/modules/active/policy.kern

11、查找/etc/init.d/目录下,所有用户都有执行权限,且其它用户有写权限的文件

[root@MyCloudServer ~]# find /etc/init.d/ -perm -113 -ls

12、查找/usr目录下不属于root、bin或hadoop的文件

[root@MyCloudServer ~]# find /usr/ -not \( -user root -o -user bin -o -user hadoop \) -ls

13、查找/etc/目录下至少有一类用户没有写权限的文件

[root@MyCloudServer ~]# find /etc/ -not -perm -222

14、查找/etc目录下最近一周内其内容被修改过,且不属于root或hadoop的文件

[root@MyCloudServer ~]# find /etc/ -mtime -7 -a -not \( -user root -o -user hadoop \) -ls

原创文章,作者:wangjinbao5566,如若转载,请注明出处:http://www.178linux.com/45755

(0)
wangjinbao5566wangjinbao5566
上一篇 2016-09-15
下一篇 2016-09-15

相关推荐

  • Linux中设置磁盘配额和RAID

    第一篇:设置磁盘配额 综述     •在内核中执行     •以文件系统为单位启用     •对不同组或者用户的策略不同       根据块或者节点进行限制         •执行软限制(soft limit)   &n…

    Linux干货 2016-09-05
  • CentOS6主机启动流程

    CentOS6主机启动流程 流程 一台Linux主机从开机到登录界面提示输入账号密码的时间中进行了好多动作,了解这些动作有助于了解Linux系统的过程,并能够对开机过程出现的故障进行troubleshooting。 主机启动后最先运行的是主板阶段,一旦电源开启,主板进行POST加点自检动作,自检完成后无故障,主板会读取BIOS信息,根据BIOS信息中的Boo…

    Linux干货 2017-05-13
  • mysql慢查询日志进行按库切割重写文件然后分析

    需求: 把每天的慢查询日志进行按库切割 对每个库的慢查询日志进行分析 思路: 工具/功能 一般统计信息 高级统计信息 脚本 优势 mysqldumpslow 支持 不支持 perl mysql官方自带 mysqlsla 支持 支持 perl 功能强大,数据报表齐全,定制化能力强. mysql-explain-slow-log 支持 不支持 perl 无 my…

    Linux干货 2015-04-03
  • 单台主机lnmp+wordpress配置示例

    单台主机lnmp+wordpress fpm配置 ]# yum install php php-fpm php-mysql –y ]# vim /etc/php-fpm.d/www.conf 配置服务监听地址和程序运行者身份 listen = 127.0.0.1:9000 user = nginx group = nginx ]# chown -R ngin…

    Linux干货 2016-11-07
  • grep与正则表达式

    grep与正则表达式 grep与正则表达式 grep 正则表达式 grep 使用语法:grep [-abcEFGhHilLnqrsvVwxy][-C<显示列数>][-e<范本样式>][-f<范本文件>][范本样式][文件或目录…]  功能说明:查找指定文件或标准输入里符合条件的字符串 常用选项 -a…

    Linux干货 2016-11-05
  • 马哥教育网络班20期+第二周课程练习

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。  答:文件管理类命令有: touch :创建一个新文件 示例:在/tmp/目录下创建一个1.log文件 touch /tmp/1.log mv:移动文件  示例:将/etc/fstab文件移至/tmp/目录中。  mv /etc/fstab /tmp/…

    Linux干货 2016-06-23