1.复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限
[root@study ~]# cp -r /etc/skel/ /home/tuser1|chmod -R 700 tuser1/ [root@study home]# ll total 4 drwx------. 4 kang kang 4096 Nov 1 06:41 kang drwx------. 2 1100 1100 59 Nov 14 07:40 linux drwx------. 2 mandriva distro 59 Nov 14 07:38 mandriva drwx------. 2 mysql mysql 59 Nov 14 08:09 mysql drwx------. 2 openstack clouds 59 Nov 14 08:06 openstack drwx------. 2 slackware distro 59 Nov 14 07:51 slackware drwx------. 2 root root 59 Nov 21 04:36 tuser1 drwx------. 2 xiaokang xiaokang 79 Nov 14 08:28 xiaokang
2.编辑/etc/group文件,添加组hadoop
[root@study home]# vi /etc/group mysql:x:3004: hadoop:x:3009 "/etc/group" 48L, 677C written
3.手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号;其家目录为/home/hadoop
[root@study home]# vi /etc/passwd mysql:x:3004:3004::/home/mysql:/sbin/nologin hadoop:x:3009:3009::/home/hadoop:/sbin/nologin ~ "/etc/passwd" 28L, 1367C written [root@study home]# id hadoop uid=3009(hadoop) gid=3009(hadoop) groups=3009(hadoop)
4.复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组合其他用户没有任何访问权限
[root@study home]# cp -r /etc/skel/ /home/hadoop|chmod -R 700 /home/hadoop [root@study home]# ll total 4 drwx------. 3 root root 70 Nov 21 04:55 hadoop
5.修改/home/hadoop目录及其内部所有文件的属主为hadoop
[root@study home]# chown -R hadoop:hadoop hadoop/|ll total 4 drwx------. 3 root root 70 Nov 21 04:55 hadoop
6.显示/proc/meminfo文件中以大写或小写S开头的行;用两种方式
[root@study home]# grep -E "^[s|S]" /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 6788 kB Slab: 52804 kB SReclaimable: 17856 kB SUnreclaim: 34948 kB [root@study home]# grep -i "^s" /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 6816 kB Slab: 52848 kB SReclaimable: 17824 kB SUnreclaim: 35024 kB
7.显示/etc/passwd文件中默认shell为非/sbin/nologin的用户
[root@study home]# grep -v "/sbin/nologin" /etc/passwd|cut -d: -f1 root sync shutdown halt kang xiaokang mandriva slackware openstack
8.显示/etc/passwd文件中其默认shell为/bin/bash的用户
[root@study home]# grep '/bin/bash' /etc/passwd|cut -d: -f1 root kang xiaokang mandriva openstack
9.找出/etc/passwd文件中的一位数或两位数
[root@study home]# grep -o "[0-9]\{1,2\}" /etc/passwd
10.显示/boot/grub2/grub.cfg中已至少一个空白字符开头的行
grep "^[[:space:]]\+" /boot/grub2/grub.cfg
11.显示/etc/rc.d/rc.local文件中以#开头,后面跟至少一个空白字符, 而后又只少一个非空白字符的行
[root@study home]# grep "^#[[:space:]]\+[^[:space:]]\+" /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
12.打出netstat -tan命令执行结果中以'LISTEN',后或跟空白字符结尾的行
[root@study home]# netstat -tan|grep "LISTEN[[:space:]]*$" tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
13.添加用户bash,testbash,basher,nologin(此一个用户的shell为/bin/nologin), 而后找出当前系统其用户名和默认shell相同的用户的信息
[root@study ~]# grep "^\([a-z]*\>\).*\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:3010:3010::/home/bash:/bin/bash nologin:x:3013:3013::/home/nologin:/bin/nologin
原创文章,作者:N24_小康,如若转载,请注明出处:http://www.178linux.com/60205