Linux基础学习总结(五)

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

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

(0)
LeexideLeexide
上一篇 2016-10-20 22:46
下一篇 2016-10-21 14:52

相关推荐

  • 内核升级和救援模式

    http://www.cnblogs.com/wzhuo/p/6728336.html 

    Linux干货 2017-04-24
  • 马哥教育网络班22期+第四周课程练习

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限 [root@localhost ~]# cp -rf /etc/skel/ /home/tuser1 &> /dev/null [root@localhost ~]# chmod -R go= /home/tus…

    Linux干货 2016-09-07
  • Linux基础命令语法

    Linux基础命令语法

    Linux干货 2018-03-11
  • grep 正则表达式 find

    1.显示当前系统上root,fedora 或user1用户的默认shell [root@centos7 ~]# grep -E  “^(root|fedora|user1)” /etc/passwd root:x:0:0:root:/root:/bin/bash fedora:x:2003:2003::/home/fedora:/bi…

    2017-09-18
  • N25-第18周博客作业

    1、为LNMP架构添加memcached支持,并完成对缓存效果的测试报告; LNMP的安装过程不再赘述. # yum install -y memcached # cat /etc/sysconfig/memcached  PORT=”11211″   &nb…

    2017-05-21
  • CPU 处理器架构知识

    CPU处理器架构: 主要有ARM、X86/Atom、MIPS、PowerPC,其中ARM在智能手机上面一枝独秀;其中ARM/MIPS/PowerPC均是基于精简指令集机器处理器的架构;X86则是基于复杂指令集的架构,Atom是x86或者是x86指令集的精简版。 Android在支持各种处理器的现状: ARM+Android 最早发展、完善的支持,主要在手机市…

    Linux干货 2015-08-03