马哥教育网络班20期第4周课程练习

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

[root@totooco home]# cp -r /etc/skel/ /home/tuser1
[root@totooco home]# chmod -R 700 /home/tuser1

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

[root@totooco home]# vim /etc/group
添加:
hadoop:x:1017:

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

[root@totooco home]# vim /etc/passwd
添加:
hadoop:x:1017:1017::/home/hadoop:/bin/bash

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

[root@totooco home]# cp -r /etc/skel/ /home/hadoop/
[root@totooco home]# chmod -R 700 /home/hadoop/

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

[root@totooco home]# chown -R hadoop:hadoop hadoop/

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

[root@totooco home]# grep "^[sS].*" /proc/meminfo
[root@totooco home]# grep -i "^s.*" /proc/meminfo

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

[root@totooco home]# grep -v "/sbin/nologin" /etc/passwd

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

[root@totooco home]# grep "/bin/bash" /etc/passwd

 

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

[root@totooco /]# egrep "\<[0-9]{1,2}\b" /etc/passwd

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

[root@totooco6 ~]# grep "^[[:space:]]\+.*" /boot/grub/grub.conf

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

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

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

[root@totooco /]# netstat -tan | grep "LISTEN[[:space:]]\?"

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

[root@totooco /]# useradd bash
[root@totooco /]# useradd testbash
[root@totooco /]# useradd basher
[root@totooco /]# useradd -s /sbin/nologin  nologin
无法完整回答.

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

[root@totooco home]# grep "^[sS].*" /proc/meminfo
[root@totooco home]# grep -i "^s.*" /proc/meminfo
[root@totooco /]# egrep "^(s|S)" /proc/meminfo

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

(0)
Net20_totoocoNet20_totooco
上一篇 2016-06-26 22:41
下一篇 2016-06-26 22:41

相关推荐

  • Linux的哲学理念

    1、由目的单一的小程序组成,通过使用者的组合形成一个能够完成复杂任务的应用程序 2、一切皆为文件 3、尽量避免捕获用户接口;也就是说Linux运行的程序大多数是不需要过多的反复输入/输出人机交互信息,运行程序命令,直接获得反馈的结果,是一种目的单一的程序 4、配置文件保存为纯文本格式

    Linux干货 2016-10-29
  • linux学习第二天知识点-linux入门及使用帮助

    一 基础命令 1. #ifconfig     显示或配置网卡的命令,英文全称是network interfaces configuring。     配置网卡的IP地址语法例:ifconfig eth0 192.168.0.1 netmask 255.255.255.0 2.&…

    Linux干货 2016-07-26
  • elk

    转载,供日后回查

    2018-07-31
  • 马哥教育网络班20期第2周课程练习

    一、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关  示例演示。 linux上文件管理命令包括: ls,cat,pwd,cp,rm,cd,head,tail,more,less,cut,which,whereis,find,mkdir,mv; 1、ls 命令;显示文件/文件夹清单   例如:如下显示列出根目录下的文件及目录…

    Linux干货 2016-06-23
  • N22-第三周作业

    1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。 ~]# who | cut -d' ' -f1| uniq -u  执行前的情况:  执行后的情况:    &nbsp…

    Linux干货 2016-09-06
  • Linux网络属性管理

      ifconfig命令 ifconfig [interface] # ifconfig -a # ifconfig IFACE [up|down] ifconfig interface [aftype] options | address … # ifconfig IFACE IP/mask [up] # ifconfig IFACE…

    Linux干货 2015-09-26

评论列表(1条)

  • 马哥教育
    马哥教育 2016-06-29 15:20

    写的很好,排版还可以在漂亮一些,加油