1. 复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限
[root@localhost ~]# chmod -R g=,o= /home/tuser1
[root@localhost home]# ll
drwx—— 3 root root 4096 Dec 26 10:43 tuser1
2. 编辑/etc/group文件,添加组hadoop
[root@localhost home]# vim /etc/group
testgrp4:x:5005:
hadoop:x:5006: <-使用g插入hadoop信息,末行模式下:x保存
distro:x:2016:
mageia:x:1100:
3. 手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号;其家目录为/home/hadoop
[root@localhost home]# vim /etc/passwd
testgrp4:x:5003:5005::/home/testgrp4:/bin/bash
hadoop:x:5004:5006::/home/hadoop:/bin/bash <-使用g插入hadoop信息,末行模式下:x保存
mageia:x:1100:1100::/home/linux:/bin/bash
4. 复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其它用户没有任何访问权限
[root@localhost ~]# chmod g=,o= /home/Hadoop 八进制赋权
[root@localhost hadoop]# chmod g-wrx,o-rwx /home/Hadoop 控制权限位赋权
5. 修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop
[root@localhost home]# chown -R hadoop:hadoop /home/hadoop/
[root@localhost home]# ll /home/hadoop/
total 4
drwxr-xr-x 3 hadoop hadoop 4096 Dec 26 10:59 skel
6. 显示/proc/meminfo文件中以大写或小写S开头的行;用两种方式
[root@localhost home]# grep "^[sS]" /proc/meminfo
[root@localhost home]# grep -i "^s" /proc/meminfo
SwapCached: 0 kB
SwapTotal: 2097144 kB
SwapFree: 2097144 kB
Slab: 16564 kB
7. 显示/etc/passwd文件中其默认shell为非/sbin/nologin的用户
[root@localhost home]# grep -v "/sbin/nologin" /etc/passwd
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
news:x:9:13:news:/etc/news:
oracle:x:500:500::/home/oracle:/bin/bash
hive:x:5000:5000:hive:/home/hive:/bin/bash
docker:x:5001:5001::/home/docker:/bin/bash
testgrp3:x:5002:5001:hello:/home/testgrp3:/bin/bash
testgrp4:x:5003:5005::/home/testgrp4:/bin/bash
hadoop:x:5004:5006::/home/hadoop:/bin/bash
mageia:x:1100:1100::/home/linux:/bin/bash
slackware:x:2002:2016::/home/slackware:/bin/tcsh
openstack:x:3003:5010::/home/openstack:/bin/bash
8. 显示/etc/passwd文件中其默认shell为/bin/bash的用户
[root@localhost home]# grep "/bin/bash" /etc/passwd9.
9. 找出/etc/passwd文件中的一位数或两位数
[root@localhost home]# grep -o "\<[0-9]\{1,2\}\>" /etc/passwd | sort –n
10. 显示/boot/grub/grub.conf中以至少一个空白字符开头的行
[root@localhost home]# grep "^[[:space:]]\+" /boot/grub/grub.conf
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-164.el5.img
11. 显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行
[root@localhost home]# grep "^#\+[[:space:]]\+[^[:space:]]" /etc/rc.d/rc.sysinit
# /etc/rc.d/rc.sysinit – run once at boot time
# /etc/init.d/diskdump swapsavecore
# Start up swapping.
…
12. 打出netstat -tan命令执行结果中以‘LISTEN’,后或跟空白字符结尾的行
[root@localhost home]# netstat -tan | grep "LISTEN[[:space:]]*$"
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:690 0.0.0.0:* LISTEN
13. 添加用户bash, testbash, basher, nologin (此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户的信息;
[root@localhost home]# grep – E "^([^:]+\>).*\1$" /etc/passwd
/etc/passwd:sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
/etc/passwd:avahi-autoipd:x:100:101:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
14. 显示/proc/meminfo文件中以大写或小写S开头的行;用三种方式
[root@localhost rc.d]# grep -i "^s" /proc/meminfo
[root@localhost rc.d]# grep "^[sS]" /proc/meminfo
[root@localhost rc.d]# grep -E "^(s|S)" /proc/meminfo
SwapCached: 0 kB
SwapTotal: 2097144 kB
SwapFree: 2097144 kB
Slab: 29744 kB
原创文章,作者:N25-笔头,如若转载,请注明出处:http://www.178linux.com/64784
评论列表(1条)
不错,完成的很好,可以看出对基础知识这块掌握的委扎实。再接再励。