4th work

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

[root@localhost etc]# cp -r /etc/skel/ /home/tuser1

[root@localhost etc]# chmod go-rwx /home/tuser1/

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

[root@localhost home]# nano /etc/group

hadoop:x:2019:

[root@localhost home]# tail -8 /etc/group

tcpdump:x:72:

oprofile:x:16:

user:x:1000:

distro:x:2016:

mageia:x:1100:

peguin:x:2017:slackware

admins:x:2018:slackware

hadoop:x:2019:

[root@localhost home]#

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

[root@localhost home]# vim /etc/passwd

hadoop:x:2003:2019::/home/hadoop:/bin/bash

[root@localhost home]# tail -3 /etc/passwd

mageia:x:1100:1100::/home/linux:/bin/bash

slackware:x:2002:2016::/home/slackware:/bin/tcsh

hadoop:x:2003:2019::/home/hadoop:/bin/bash

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

[root@localhost home]# cp -r /etc/skel/ /home/hadoop

[root@localhost home]# chmod go= hadoop/

[root@localhost home]# ll -d hadoop/

drwx——. 3 root root 78 Oct  8 23:26 hadoop/

[root@localhost home]#

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

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

[root@localhost home]# ll hadoop/ -a

total 12

drwx——.  3 hadoop hadoop  78 Oct  8 23:26 .

drwxr-xr-x. 11 root   root   130 Oct  8 23:26 ..

-rw-r–r–.  1 hadoop hadoop  18 Oct  8 23:26 .bash_logout

-rw-r–r–.  1 hadoop hadoop 193 Oct  8 23:26 .bash_profile

-rw-r–r–.  1 hadoop hadoop 231 Oct  8 23:26 .bashrc

drwxr-xr-x.  4 hadoop hadoop  39 Oct  8 23:26 .mozilla

[root@localhost home]#

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

方法一、

[root@localhost home]# cat /proc/meminfo  | grep -i “^s.*”

方法二、

[root@localhost home]# cat /proc/meminfo  | grep -E  “^(S|s).*”

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

[root@localhost home]# grep -v “/sbin/nologin” /etc/passwd | cut -d: -f1

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

[root@localhost home]# grep “/bin/bash” /etc/passwd | cut -d: -f1

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

[root@localhost home]# grep -E -o  “\<[0-9]{1,2}\>” /etc/passwd

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

[root@localhost grub2]# grep -E “^[[:space:]]+” /boot/grub2/grub.cfg

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

[root@localhost etc]# grep -E “^#[[:space:]]+[^[:space:]]+” /etc/rc.d/init.d/functions

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

[root@localhost etc]# netstat -tan | grep -E  “\<LISTEN\>[[:space:]]+”

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

[root@localhost etc]# useradd bash

[root@localhost etc]# useradd testbash

[root@localhost etc]# useradd basher

[root@localhost etc]# useradd -s /sbin/nologin nologin

[root@localhost etc]# grep -E “(^\<[[:alnum:]]+\>).*\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:2004:2004::/home/bash:/bin/bash

nologin:x:2007:2007::/home/nologin:/sbin/nologin

[root@localhost etc]#

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/87671

(0)
N27_zhangweitaoN27_zhangweitao
上一篇 2017-10-08 20:17
下一篇 2017-10-09 08:53

相关推荐

  • 进程,自动化任务与安全

    进程     进程就是一段存储了一个指令集的内存空间    相关命令:        pstree:显示当前运行的进程树,按树状结构显示     &n…

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

    1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)     系统启动流程:       POST –> BootSequence(BIOS) –> BootLoader …

    Linux干货 2016-10-27
  • vim编辑以及脚本编程练习

    vim编辑器的使用总结: vim在工作过程当中有三种模式:编辑模式、输入模式、末行模式。 1、编辑模式:即命令模式,键盘操作常被理解为编辑命令; 2、输入模式:在文本文件当中进行输入内容; 3、末行模式:vim内置的命令行接口,执行vim的内置命令。   vim的使用 打开文件 #vim[option]…[FILE] +#:打开文件后,直接让光标处…

    Linux干货 2017-10-29
  • sed的用法小结

    sed的用法小结 sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等sed [OPTION]… ‘script’ [input-file] … OPTION: -n 不输出模式空间中的内容至屏幕,仅显示script处理后的结果 -e 多点编辑,eg: ~]# sed -e ‘s@^#[[…

    Linux干货 2017-08-22
  • yum相关知识及源码编译安装http

    二.源码编译安装http 获得源码,将源码放在/usr/local/src下,并将其解压缩到此目录下 进入解压缩文件下,查看INSTALL文件 文件内容如下 黄色区域即为安装步骤 在当前目录下执行./configure –prefix=/usr/local/appach2 编译  make make install  把目标文…

    系统运维 2016-08-24
  • 逻辑卷管理

    逻辑卷管理 一 创建逻辑卷 1 准备分区或硬盘 这里使用/dev/sdb、/dev/sdc两块硬盘和/dev/sda9、/dev/sda10两个分区,大小都为1G,磁盘有限,我也不想这么抠的。 添加分区/dev/sda9、 /dev/sda10 [root@centos7 ~]# fdisk /dev/sda Welcome to fdisk (u…

    Linux干货 2017-05-02