1.复制/etc/skel 目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其他用户均没有任何访问权限
cp /etc/skel /home/tuser1 -rf
chmod og= /home/tuser1 -R
2.编辑/etc/group文件添加组hadoop
echo hadoop:x:503 >>/etc/group
3.手动编辑/etc/passwd 文件新增一行,添加用户hadoop,其基本组ID为hadoop组的ID号,其家目录为/home/hadoop.
# echo hadoop:x:503:503::/home/hadoop:/bin/bash >>/etc/passwd
# tail -1 /etc/passwd
hadoop:x:503:503::/home/hadoop:/bin/bash
4.复制/etc/ske1目录为/home/hadoop,要求修改hadoop目录的属组和其他用户没有任何访问权限
# cp /etc/skel/ /home/hadoop -rf
# chmod og= /home/hadoop -R
5.修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop
# chown -R hadoop.hadoop /home/hadoop -R
6.显示/proc/meminfo文件中以大写或小写S开头的行,两种方式
方式一:
# cat /proc/meminfo |grep -i ^s
SwapCached: 2676 kB
SwapTotal: 2031608 kB
SwapFree: 2018740 kB
Shmem: 8 kB
Slab: 62448 kB
SReclaimable: 9320 kB
SUnreclaim: 53128 kB
方式二:
# egrep “^(s|S)” /proc/meminfo
SwapCached: 2676 kB
SwapTotal: 2031608 kB
SwapFree: 2018740 kB
Shmem: 8 kB
Slab: 62488 kB
SReclaimable: 9364 kB
SUnreclaim: 53124 kB
7.显示/etc/passwd文件中其默认Shell 为非/sbin/nologin得用户
# grep -v “/sbin/nologin” /etc/passwd|awk -F “:” ‘{print $1}’
root
sync
shutdown
halt
nginx
user3
tuser1
test2
hadoop
8.显示/etc/passwd 文件中其默认Shell 为/bin/bash的用户
# grep “/bin/bash” /etc/passwd|awk -F “:” ‘{print $1}’
root
nginx
user3
tuser1
test2
hadoop
9.找出/etc/passwd 文件中的一位数或者两位数
grep -E -o “(“[0-9]”|”[0-9][0-9]”)” /etc/passwd
10,显示/boot/grub/grub.conf中以至少一个空白字符开头的行;
# grep “^[[:space:]]\+” /boot/grub/grub.conf
11.显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;
#grep “^[#][[:space:]]+.*[^[:space:]]+.*” /etc/rc.d/rc.sysinit
12,打出netstat -tan命令执行结果中以’LISTEN’,后或跟空白字符结尾的行;
# netstat -tan | grep “LISTEN[[:space:]]*$”
13,添加用户bash,testbash,basher,nologin(此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户的信息
#useradd bash
# useradd testbash
# useradd basher
#useradd nologin -s /sbin/nologin
# tail -4 /etc/passwd
bash:x:504:504::/home/bash:/bin/bash
testbash:x:505:505::/home/testbash:/bin/bash
basher:x:506:506::/home/basher:/bin/bash
nologin:x:507:507::/home/nologin:/sbin/nologin
# grep -E “^([^:]+)\>.*\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:504:504::/home/bash:/bin/bash
nologin:x:507:507::/home/nologin:/sbin/nologin
14.显示/proc/meminfo文件中以大写或者小写S开头的行;三种方式
方式一:
# cat /proc/meminfo |grep -i ^s
SwapCached: 2676 kB
SwapTotal: 2031608 kB
SwapFree: 2018740 kB
Shmem: 8 kB
Slab: 62448 kB
SReclaimable: 9320 kB
SUnreclaim: 53128 kB
方式二:
# egrep “^(s|S)” /proc/meminfo
SwapCached: 2676 kB
SwapTotal: 2031608 kB
SwapFree: 2018740 kB
Shmem: 8 kB
Slab: 62488 kB
SReclaimable: 9364 kB
SUnreclaim: 53124 kB
方式三:
# grep “^[Ss]\+” /proc/meminfo
SwapCached: 2700 kB
SwapTotal: 2031608 kB
SwapFree: 2018748 kB
Shmem: 12 kB
Slab: 100668 kB
SReclaimable: 45276 kB
SUnreclaim: 55392 kB
原创文章,作者:N24_liuz,如若转载,请注明出处:http://www.178linux.com/60271
评论列表(1条)
整体完成的不错,第5题多个-R