1.復(fù)制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內(nèi)部文件的屬組和其他用戶均沒有任何訪問權(quán)限
[root@centos-7 ~]# cp -r /etc/skel /home/tuser1
[root@centos-7 ~]# chmod -R 700 /home/tuser1
[root@centos-7 ~]# ls -al /home/tuser1/
total 12
drwx------. 4 root root 90 Nov 21 18:28 .
drwxr-xr-x. 16 root root 192 Nov 21 17:57 ..
-rwx------. 1 root root 18 Nov 21 17:57 .bash_logout
-rwx------. 1 root root 193 Nov 21 17:57 .bash_profile
-rwx------. 1 root root 231 Nov 21 17:57 .bashrc
drwx------. 4 root root 39 Nov 21 17:57 .mozilla
drwx------. 3 root root 78 Nov 21 18:28 skel
2.編輯/etc/group文件何暇,添加組hadoop
admins:x:2018:slackware
hadoop:x:8888:
[root@centos-7 ~]# echo "hadoop:x:8888:" >> /etc/group
3.手動編輯/etc/passwd文件新增一行耽装,增加用戶hadoop肿轨,其基本組ID為hadoop組的ID號别垮;其家目錄為/home/hadoop
[root@centos-7 ~]# echo "hadoop:x:8888:8888::/home/hadoop:/bin/bash" >> /etc/passwd
[root@centos-7 ~]# grep 'hadoop' /etc/passwd
hadoop:x:8888:8888::/home/hadoop:/bin/bash
4.復(fù)制/etc/skel目錄為/home/hadoop庭瑰,要求修改hadoop目錄的屬組和其他用戶沒有任何訪問權(quán)限
[root@centos-7 ~]# cp -r /etc/skel /home/hadoop
[root@centos-7 ~]# chown -R hadoop /home/hadoop
[root@centos-7 ~]# chgrp -R hadoop /home/hadoop
[root@centos-7 ~]# chmod -R 700 /home/hadoop
5.修改/home/hadoop目錄及其內(nèi)部所有文件的屬主為hadoop枪狂,屬組為hadoop
[root@centos-7 hadoop]# chown -R hadoop /home/hadoop
[root@centos-7 hadoop]# chgrp -R hadoop /home/hadoop
[root@centos-7 hadoop]# ls -al
total 12
drwx------. 4 hadoop hadoop 90 Nov 21 20:13 .
drwxr-xr-x. 17 root root 206 Nov 21 19:33 ..
-rwx------. 1 hadoop hadoop 18 Nov 21 19:33 .bash_logout
-rwx------. 1 hadoop hadoop 193 Nov 21 19:33 .bash_profile
-rwx------. 1 hadoop hadoop 231 Nov 21 19:33 .bashrc
drwx------. 4 hadoop hadoop 39 Nov 21 19:33 .mozilla
drwx------. 3 hadoop hadoop 78 Nov 21 20:13 skel
6.顯示/proc/meminfo文件中以大寫或小寫S開頭的行危喉,用兩種方式
[root@centos-7]# grep "^[Ss]" /proc/meminfo
[root@centos-7]# grep -i ^'s' /proc/meminfo
7.顯示/etc/passwd文件中其默認shell為非/sbin/nologin的用戶
[root@centos-7 hadoop]# grep '/sbin/nologin'$ /etc/passwd | cut -d: -f1
8.顯示/etc/passwd文件中默認shell為/bin/bash用戶
[root@centos-7 hadoop]# grep '/bin/bash'$ /etc/passwd | cut -d: -f1
9.找出/etc/paawd文件中的一位數(shù)或兩位數(shù)
grep "\<[0-9]\{1,2\}\>" /etc/passwd
10.顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行
[root@centos-7 hadoop]# grep "^[[:space:]]\{1,\}" /boot/grub/grub.conf
11.顯示/etc/rc.d/rc.sysinit文件中以#開頭,后面至少一個空白字符州疾,而后面至少一個非空白字符的行
[root@centos-7 hadoop]# grep "^#[[:space:]]\{1,\}[^[:space:]]\{1,\}" /etc/rc.d/rc.local
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
12.打出netstat -tan命令執(zhí)行結(jié)果中以 LISTEN姥饰,后或跟空白符結(jié)尾的行
[root@centos-7 hadoop]# netstat -tan | grep "\<LISTEN\>\|[[:space:]]\{0,\}$"
13.添加用戶bash,testbash,basher,nologin(此用戶的shell為/sbin/nologin),而后找出系統(tǒng)上其用戶名和默認shell相同的用戶的信息
[root@centos-7 ~]# grep "\(^.*\):.*\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:1003:1007::/home/bash:/bin/bash
sh:x:1006:1010::/home/sh:/bin/bash
nologin:x:1007:1011::/sbin/nologin:/sbin/nologin