马哥教育网络班20期-第四周课程作业

1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其他用户均没有任何访问权限。

      cp -r /etc/skel /home/tuser1 | chmod -R g-rx,o-rx /home/tuser1/

     

2、编辑/etc/group文件,添加组hadoop

       echo "hadoop:x:1103:" >> /etc/group

    /etc/group文件内格式一般为: 组名:口令:组标识号:组内用户列表         


3、手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号,其家目录为/home/hadoop

    echo "hadoop:x:1010:1103:/home/hadoop:/bin/bash" /etc/passwd 

     /etc/passwd文件内的格式一般为:

    用户名: 密码 : uid  : gid :用户描述:主目录:登陆默认shell

4、复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其他用户没有任何访问权限

    cp -r /etc/skel /home/hadoop |chmod g-rx,o-rx /home/hadoop

5、修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop

    chown -R hadoop:hadoop /home/hadoop

    用法: chown [OPTION]… [OWNER][:[GROUP]] FILE…

6、显示/proc/meminfo文件中以大写或小写S开头的行,用两种方式

    grep -i "^s" /proc/meminfo

    grep "^[s,S]" /proc/meminfo

7、显示/etc/passwd文件中其默认shell为非/sbin/nologin的用户

    grep -v "/sbin/nologin" /etc/passwd

8、显示/etc/passwd文件中其默认shell为/bin/bash的用户

    grep "/bin/bash" /etc/passwd


9、找出/etc/passwd文件中的一位数或两位数

    grep "\<[0-9]\{2,3\}" /etc/passwd


10、显示/boot/grub/grub.conf中以至少一个空白字符开头的行

     grep "^[[:space:]]\+" /boot/grub/grub.conf

        

11、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行

    grep "^#[[:space:]]^[[:space:]]\+" /etc/rc.d/rc.sysinit


12、打出netstat -tan 命令执行结果中以‘LISTEN',后跟0,1或跟空白字符结尾的行;

     netstat -tan | grep 'LISTEN[01[[:space:]]]$' 


13、添加用户bash,testbash,basher,nologin(此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认的shell相同的用户信息

    useradd bash

    useradd testbash

    useradd basher

    useradd -s /sbin/nologin nologin 

    grep "^\([[:alnum:]]\+\>\).*\1$" /etc/passwd


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

(0)
Net20_KenNet20_Ken
上一篇 2016-06-29 14:29
下一篇 2016-06-29 14:29

相关推荐

  • N26-第四周

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

    Linux干货 2017-02-22
  • Homework Week-13 samba、vsftp文件共享

    1、建立samba共享,共享目录为/data,要求:(描述完整的过程)   1)共享名为shared,工作组为magedu;   2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名;   3)添加s…

    Linux干货 2016-12-05
  • vim编辑器-练习题

    1 、复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的行首的空白字符 #cp /etc/profile /tmp #vim /tmp/profile :%s/^[[:space:]]\+// 2 、复制/etc/rc.d/init.d/functions 文件至/tmp 目录,用查找替换命令为/tmp/func…

    Linux干货 2016-08-15
  • 重定向、管道——Linux基本命令(9)

    1.     输出重定向 Linux默认输入是键盘,输出是显示器。可以用重定向来改变这些设置。比如用wc命令的时候本来是要手动输入一篇文字来计算字符数的,可以直接把一个已经写好的文件用‘<’指向这条命令,就直接可以统计这个文件的字符数等了。   STDOUT(标准输出)和STDERR(标准错误)可以被重…

    2017-07-20
  • 马哥教育网络班22期+第四周课程练习

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 ~]# cp -r /etc/skel/ /home/tuser1/ ~]# chmod 700 /home/tuser1/ -R 2、编辑/e…

    Linux干货 2016-09-06
  • 推荐-File System manager

    文件系统(File system) :     文件系统概要    文件系统的分类    文件系统的管理工具             mkfs btrfs ext xfs&nbsp…

    Linux干货 2016-03-26

评论列表(1条)

  • 马哥教育
    马哥教育 2016-06-29 14:51

    写的很好,但是有的题是让手动编辑,还有可以多关注一下排版的问题