第五周作业

1、显示当前系统上rootfedorauser1用户的默认shell
答:#egrp ‘^(root|fedora|user1)’ /etc/passwd | cut -f1,7 -d:
2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello()
答:#egrp -o “\<[[:almnum:]]+\>\(\)” /etc/rc.d/init.d/functions
3、使用echo命令输出一个绝对路径,使用grep取出其基名;
    扩展:取出其路径名
答:echo “val/www/html”| grep -oE “[^/]+/?$” | cut -d/ -f1
    echo “/usr/www/html” | grep -oE  “^/(.*)/”
4、找出ifconfig命令结果中的1-255之间数字;
答:#ifconfig | grep -oE “\<([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>”
5、挑战题:写一个模式,能匹配合理的IP地址;
答:ifconfig | grep -oE “(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)”
6、挑战题:写一个模式,能匹配出所有的邮件地址;
答:grep -oE “[[:alnum:]]+@[[:alnum:]]+\.[ A-Za-z]{2,3}”
7、查找/var目录下属主为root,且属组为mail的所有文件或目录;
答:find /var -user root -a -group mail
8、查找当前系统上没有属主或属组的文件;
     进一步:查找当前系统上没有属主或属组,且最近3天内曾被访问过的文件或目录;
答:find / \( -nouser -o -nogroup \)
    find / \( -nouser -o -nogroup \) -a -atime -3
9、查找/etc目录下所有用户都有写权限的文件;
答:find /etc -perm /222
10、查找/etc目录下大于1M,且类型为普通文件的所有文件;
答:find /etc -size +1M -type f
11、查找/etc/init.d/目录下,所有用户都有执行权限,且其它用户有写权限的文件;
答:find /etc/init.d -perm /113
12、查找/usr目录下不属于rootbinhadoop的文件;
答:find /usr -not \( -user root -o -user bin -o -user hadoop \)
13、查找/etc/目录下至少有一类用户没有写权限的文件;
答:find /etc -not -perm /222
14、查找/etc目录下最近一周内其内容被修改过,且不属于roothadoop的文件;
答:find /etc -mtime -7 -a -not \( -user root -o -user hadoop \)

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

(0)
N24_shishenN24_shishen
上一篇 2017-02-25 21:46
下一篇 2017-02-25 22:47

相关推荐

  • Linux基础知识(六)-vim编辑器,crontab计划任务,bash脚本循环

    1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#; [root@localhost ~]# cp /etc/rc.d/rc.sysinit /tmp [root@localhost ~]# vim&nbs…

    Linux干货 2016-10-31
  • 一键搭建mysql集群系列二

    mysql 5.7  主从复制 本节是在上一节的基础之上做的操作,上节我们通过脚本实现了一键自动化安装mysql5.7,这次我们要在三台机器上部署msyql5.7,并实现主从复制,实现的宗旨是,能自动化,就尽量自动化,实在不能自动化,那就手工化 用的脚本和文件说明1.install_mysql.sh 自动化安装mysql脚本2.ntpdate.sh 时间同步…

    2017-05-21
  • 自制Linux

    1. 分区出来两个区 fdisk /dev/sdb     2. 创建文件系统   [root@localhost ~]# mkfs.ext4 /dev/sdb1  [root@localhost ~]# mkfs.ext4 /dev/sdb2 3.…

    Linux干货 2016-09-16
  • MongoDB安装部署手稿

    Edit MongoDB 手册 MongoDB 手册 第一章 Introduction MongoDB入门学习目录(建议) Databases Collections Documents 第二章 部署安装 1. Import the MongoDB public key 2. Configure the package management system (…

    Linux干货 2016-03-26
  • linux用户权限管理

    用户: 管理员–root= 0 普通用户–(1-65535) 系统用户–(1-499),(1-999) 登录用户–(500+),(1000+) 用户和组的配置文件位置: /etc/passwd– 存储系统用户所有信息 /etc/group– 存储用户组的所有信息 /etc/shadow&…

    2017-04-02
  • 马哥Linux第三周作业

    正则表达式 用户和组管理

    Linux干货 2017-12-31

评论列表(1条)

  • 马哥教育
    马哥教育 2017-03-06 19:01

    注意字符,写作业时,请测好你的答案,find /etc -perm /222 这是什么意思?