马哥教育网络班22期+第5周课程练习

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

[root@rhel677850 ~]# grep "^\(root\|fedora\|user1\)" /etc/passwd|awk -F: '{print $1,$7}'
root /bin/bash
[root@rhel677850 ~]# egrep "^(root|fedora|user1)" /etc/passwd|awk -F: '{print $1,$7}'
root /bin/bash

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

[root@rhel677850 ~]# egrep "[[:alpha:]]+\(\)" /etc/rc.d/init.d/functions
fstab_decode_str() {
checkpid() {
__readlink() {
__fgrep() {
__umount_loop() {
__umount_loopback_loop() {
__pids_var_run() {
__pids_pidof() {
daemon() {
killproc() {
pidfileofproc() {
pidofproc() {
status() {
echo_success() {
echo_failure() {
echo_passed() {
echo_warning() {
update_boot_stage() {
success() {
failure() {
passed() {
warning() {
action() {
action_silent() {
strstr() {
confirm() {
get_numeric_dev() {
is_ignored_file() {
is_true() {
is_false() {
apply_sysctl() {
key_is_random() {
find_crypto_mount_point() {
init_crypto() {

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

[root@rhel677850 ~]# echo "/etc/passwd"|grep -o "[^/]\+$"
passwd
使用grep取路径名
[root@rhel677850 ~]# echo "/etc/passwd"|grep -o ".*/"
/etc/

4、找出ifconfig命令结果中的1-255之间数字;

[root@rhel677850 ~]# ifconfig | egrep -o "\<([1-9]|[1-9][0-9]|1[0-9][0-9]|[2[0-4][0-9]|25[0-5]])\>"

5、挑战题:写一个模式,能匹配合理的IP地址;

[root@rhel677850 ~]# ifconfig | egrep -o "(\<([1-9]|[1-9][0-9]|1[0-9][0-9]|[2[0-4][0-9]|25[0-5]])\>\.){3}\<([1-9]|[1-9][0-9]|1[0-9][0-9]|[2[0-4][0-9]|25[0-5]])\>"
10.31.78.50

6、挑战题:写一个模式,能匹配出所有的邮件地址;

[root@rhel677850 ~]# egrep "[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$"   mail.txt
zhangxialoa@mageedu.com
318810@qq.com

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

[root@rhel677850 ~]# ls -l /var | awk '/\<root mail\>/{print $NF}'

8、查找当前系统上没有属主或属组的文件;

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

进一步:查找当前系统上没有属主或属组,且最近3天内曾被访问过的文件或目录;

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

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

[root@rhel677850 ~]# find / -perm -222

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

[root@rhel677850 ~]# find /etc/ -size +1M -type f
/etc/pki/tls/certs/ca-bundle.trust.crt
/etc/selinux/targeted/modules/active/policy.kern
/etc/selinux/targeted/policy/policy.24
/etc/gconf/gconf.xml.defaults/%gconf-tree.xml

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

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

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

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

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

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

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

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

原创文章,作者:zhangxiaola,如若转载,请注明出处:https://www.178linux.com/47831

赞 (0)
zhangxiaolazhangxiaola
上一篇 2016-09-26 07:43
下一篇 2016-09-26 07:43

相关推荐

  • 程序包管理:rpm , yum ,与编译

    1.RPM,Redhat Package Manager。是Redhat和CentOS等Linux系统上常见的软件安装工具。 软件安装: 常见选项 -i                #install…

    Linux干货 2016-03-26
  • sed工具 vim编辑器

    sed工具:    用法:           sed [option]… 'script' inputfile…      常用选项:           &nbs…

    Linux干货 2016-08-12
  • Linux软件包管理

      在我们的运维工作,总是避免不了安装某些软件,或者编译安装某些软件,我们知道操作系统当中的程序都是有程序员通过开发工具开发的来,程序员直接编写的纯文本的文档我们称之为源代码,但我们的计算机只能识别二进制程序,那么必须要将源代码变成计算机能识别的二进制程序,这里需要通过编译器来进行编译,将源码转换成二进制程序,再通过安装即可。 还有一类程序就是二进…

    Linux干货 2016-08-24
  • shell 脚本编程基础

    Shell脚本简介: Shell脚本是一种特殊的程序,它是用户与linux系统内核之间的一个接口,shell是一个工具程序,在用户登录后系统启动。它解释并运行由命令行或脚本文件输入的命令,从而实现用户与内核间的交互。 Shell脚本:也就是用各类命令预先放入到一个文件中,方便一次性执行的一个程序文件,主要是方便管理员进行设置或者管理用的,是利用shell的功…

    Linux干货 2016-08-21
  • 9月9日,系统启动文件恢复与内核编译

    1、破解root口令,并为grub设置保护功能 进入grub界面,输入a键,在输入1,进入单用户界面,进入系统后修改密码。 2、破坏本机grub stage1,而后在救援模式下修复之 3、删除vmlinuz和initramfs文件,无法启动,恢复之 (1)安装kernel内核 (2)光盘寻找内核,在复制到/boot目录下,在修改成对应的,系统会重启两次 (3…

    Linux干货 2016-09-13
  • mitaka版本openstack网络之open vSwitch

    作者:【吴业亮】 博客:http://blog.csdn.net/wylfengyujiancheng 一、硬件配置及服务拓扑1. controller节点:一块网卡2. 网络节点:四块网卡。3. 计算节点:三块网卡 controller节点1. 运行 neutron数据库2. 运行消息队列服务3. 运行认证。4. 运行OpenStack计算nova相关网络…

    2018-01-22

评论列表(1条)

  • 马哥教育
    马哥教育 2016-09-27 09:56

    写的很好,看的出来很用心,不过还是要注意排版的问题,希望继续保持