马哥教育网络20期+第四周练习博客

要求:

1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。
2、编辑/etc/group文件,添加组hadoop。
3、手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号;其家目录为/home/hadoop。
4、复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其它用户没有任何访问权限。
5、修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop。
6、显示/proc/meminfo文件中以大写或小写S开头的行;用两种方式;
7、显示/etc/passwd文件中其默认shell为非/sbin/nologin的用户;
8、显示/etc/passwd文件中其默认shell为/bin/bash的用户;
9、找出/etc/passwd文件中的一位数或两位数;
10、显示/boot/grub/grub.conf中以至少一个空白字符开头的行;
11、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;
12、打出netstat -tan命令执行结果中以‘LISTEN’,后或跟空白字符结尾的行;
13、添加用户bash, testbash, basher, nologin (此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户的信息;

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

[root@Centos6 home]# ll /etc/skel/
total 0
-rw-r--r-- 1 root mysql 0 Jul  1 20:49 1
-rw-r--r-- 1 root mysql 0 Jul  1 20:49 2
-rw-r--r-- 1 root mysql 0 Jul  1 20:49 3
-rw-r--r-- 1 root mysql 0 Jul  1 20:49 4
[root@Centos6 home]# cp -rf /etc/skel/ tuser1
[root@Centos6 home]# ll tuser1
total 0
-rw-r--r-- 1 root mysql 0 Jul  1 20:51 1
-rw-r--r-- 1 root mysql 0 Jul  1 20:51 2
-rw-r--r-- 1 root mysql 0 Jul  1 20:51 3
-rw-r--r-- 1 root mysql 0 Jul  1 20:51 4
[root@Centos6 home]# chmod -R go-rwx tuser1
[root@Centos6 home]# ll tuser1
total 0
-rw------- 1 root mysql 0 Jul  1 20:51 1
-rw------- 1 root mysql 0 Jul  1 20:51 2
-rw------- 1 root mysql 0 Jul  1 20:51 3
-rw------- 1 root mysql 0 Jul  1 20:51 4
[root@Centos6 home]#

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

[root@Centos6 home]# tail -n 1 /etc/group
nginx:x:492:
[root@Centos6 home]# echo "hadoop:x:600:" >> /etc/group
[root@Centos6 home]# tail -n 1 /etc/group
hadoop:x:600:
[root@Centos6 home]#


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

[root@Centos6 home]# tail -n 1 /etc/passwd
nginx:x:398:492::/home/nginx:/bin/bash
[root@Centos6 home]# echo "hadoop:x:601:600::/home/hadoop:/bin/bash" >> /etc/passwd
[root@Centos6 home]# tail -n 1 /etc/passwd
hadoop:x:601:600::/home/hadoop:/bin/bash
[root@Centos6 home]#

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

[root@Centos6 home]# cp -rf /etc/skel/ /home/hadoop && chmod -R og-xwr /home/hadoop
[root@Centos6 home]# ll hadoop/
total 0
-rw------- 1 root mysql 0 Jul  1 21:00 1
-rw------- 1 root mysql 0 Jul  1 21:00 2
-rw------- 1 root mysql 0 Jul  1 21:00 3
-rw------- 1 root mysql 0 Jul  1 21:00 4
[root@Centos6 home]#

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

[root@Centos6 home]# chown -R hadoop:hadoop hadoop
[root@Centos6 home]# ll hadoop/
total 0
-rw------- 1 hadoop hadoop 0 Jul  1 21:00 1
-rw------- 1 hadoop hadoop 0 Jul  1 21:00 2
-rw------- 1 hadoop hadoop 0 Jul  1 21:00 3
-rw------- 1 hadoop hadoop 0 Jul  1 21:00 4
[root@Centos6 home]#

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

[root@Centos6 home]# grep -i "^s" /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       2031612 kB
SwapFree:        2031612 kB
Shmem:               364 kB
Slab:              99328 kB
SReclaimable:      72176 kB
SUnreclaim:        27152 kB
[root@Centos6 home]# grep  "^s" /proc/meminfo 
[root@Centos6 home]# grep  "^[sS]" /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       2031612 kB
SwapFree:        2031612 kB
Shmem:               364 kB
Slab:              99360 kB
SReclaimable:      72172 kB
SUnreclaim:        27188 kB
[root@Centos6 home]#

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

[root@Centos6 home]# grep -v "/sbin/nologin$" /etc/passwd | cut -d: -f1 
root
sync
shutdown
halt
test
test200
test401
nologin
mysql
gentoo
centos
ubuntu
nginx
hadoop
[root@Centos6 home]#

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

[root@Centos6 home]# grep  "/bin/bash$" /etc/passwd | cut -d: -f1
root
test
test200
test401
mysql
gentoo
centos
ubuntu
nginx
hadoop
[root@Centos6 home]#

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

[root@Centos6 home]# grep -o "[0-9]\{1,2\}" /etc/passwd

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

[root@Centos6 home]# grep "^[[:space:]]\+" /boot/grub/grub.conf

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

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

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

[root@Centos6 home]# netstat -tan | grep "LISTEN[[:space:]]*$"


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

[root@Centos6 home]# useradd bash
[root@Centos6 home]# useradd testbash
[root@Centos6 home]# useradd basher
[root@Centos6 home]# useradd -s /sbin/nologin nologin

[root@Centos6 home]# grep -E '^(\<[a-z]+\>).*\1$' /etc/passwd
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
bash:x:602:602::/home/bash:/bin/bash
nologin:x:605:605::/home/nologin:/sbin/nologin




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

(0)
Net20-deamonNet20-deamon
上一篇 2016-07-02 10:47
下一篇 2016-07-02 15:44

相关推荐

  • ldirectord 结合ipvsadm 配置nat,dr模型

    ldirectord 结合ipvsadm 配置nat,dr模型  一、nat模型 1、 drector # wget ftp://172.16.0.1/pub/Sources/7.x86_64/crmsh/ldirectord-3.9.6-0rc1.1.1.x86_64.rpm # yum -y install nginx (同…

    Linux干货 2016-11-24
  • 马哥教育网络20期+第四周练习博客

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 cp -r /etc/skel /home/tuser1|chmod go-rwx /home/tuser1 2、编辑/etc/group文件,添加组hadoop。 &nbs…

    2016-07-04
  • httpd协议配置进阶

    目录 虚拟主机配置 status状态页面 curl命令 mod_deflate模块 https配置 httpd自带应用程序 虚拟主机配置 有三种实现方案:    基于IP:        为每个虚拟主机准备至少一个IP地址    基于端口:     &nbsp…

    Linux干货 2016-10-31
  • 第一次写的linux脚本

    刚开始学的时候,都是一些基本的命令,总是无法把它们联系到一块去,现在刚开始接触脚本,顿时感觉压力好大,基础命令如果记不牢,很有可能就挂了,下面我把近几天学习的一些脚本命令及练习拿来分享一下,供大家参考,同时加深我的记忆。 首先是写脚本的格式,我这里用vim编辑器来写的脚本,因为它的色彩非常明艳,易于区分。基本格式如下: #!/bin/bash 第一行一般为调…

    Linux干货 2017-08-05
  • 马哥教育网络班21期-第三周课程练习

    1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。[root@MyServer ~]# who |cut -d' ' -f1|sort |uniq -c|cut -d' ' -f8root[root@MyServer ~]# who | cut -d' ' -f1 | s…

    2016-07-26
  • centOS6.9 防火墙的关闭以及开启

    有的时候,我们需要对系统的防火墙进行操作,今天小编就给大家讲解一下如何开启以及关闭CentOS6.9系统下的防火墙。 输入:cat /etc/issue 查看版本 (一)通过service命令 service命令开启以及关闭防火墙为即时生效,下次重启机器的时候会自动复原。 查看防火墙状态:service iptables status ,记得在CentOS6…

    Linux笔记 2018-04-20

评论列表(1条)

  • 马哥教育
    马哥教育 2016-07-04 13:57

    写的很好,排版可以多关注一下,加油