1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其他用户均没有任何访问权限。
[root@localhost home]# cp -r /etc/skel/ /home/tuser1 [root@localhost home]# chmod 700 tuser1/ [root@localhost home]# ll -d tuser1 /drwx------ 2 root root 59 10月 16 18:48 tuser1/
2、编辑/etc/group文件,添加组Hadoop。
[root@localhost home]# tail -1 /etc/grouphadoop:x:1001:
3、手动编辑/etc/passwd文件,增加一行,添加用户Hadoop,其基本组为ID为Hadoop的组ID号,其家目录为/home/hadoop.
[root@localhost home]# cp -r /etc/skel/ /home/hadoop [root@localhost home]# vim /etc/passwd [root@localhost home]# tail -1 /etc/passwdhadoop:x:1001:1001::/home/hadoop:/bin/bash [root@localhost home]# su - hadoop [hadoop@localhost ~]$ id hadoop uid=1001(hadoop) gid=1001(hadoop) 组=1001(hadoop)
4、复制/etc/skel目录为/home/hadoop,要求修改Hadoop的目录的属组和其他用户没有任何访问权限。
[root@localhost home]# ll -d /home/hadoop/ drwxr-xr-x 2 root root 59 10月 16 18:54 /home/hadoop/ [root@localhost home]# chown -R hadoop.hadoop /home/hadoop/ [root@localhost home]# chmod -R 700 /home/hadoop/ [root@localhost home]# ll -d /home/hadoop/ drwx------ 2 hadoop hadoop 59 10月 16 18:54 /home/hadoop/
5、修改/home/hadoop目录及其内部所有文件的属主为Hadoop,属组为Hadoop
[root@localhost home]# chown -R hadoop.hadoop /home/hadoop/ [root@localhost home]# ll -a /home/hadoop/ 总用量 12 drwx------ 2 hadoop hadoop 59 10月 16 18:54 . drwxr-xr-x. 6 root root 56 10月 16 18:54 .. -rwx------ 1 hadoop hadoop 18 10月 16 18:54 .bash_logout -rwx------ 1 hadoop hadoop 193 10月 16 18:54 .bash_profile -rwx------ 1 hadoop hadoop 231 10月 16 18:54 .bashrc
6、显示/proc/meminfo文件中以大写或小写s开头的行;用两种方式
[root@localhost home]# egrep "^[Ss]" /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 6836 kB Slab: 35932 kB SReclaimable: 14572 kB SUnreclaim: 21360 kB [root@localhost home]# grep -i "^s" /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 6836 kB Slab: 35932 kB SReclaimable: 14572 kB SUnreclaim: 21360 kB
7、显示/etc/passwd文件中其默认登录shell为/sbin/nologin的用户;
[root@localhost home]# cut -d: -f1,7 /etc/passwd | grep "/sbin/nologin"bin:/sbin/nologin daemon:/sbin/nologin adm:/sbin/nologin lp:/sbin/nologin mail:/sbin/nologin operator:/sbin/nologin games:/sbin/nologin ftp:/sbin/nologin nobody:/sbin/nologin avahi-autoipd:/sbin/nologin systemd-bus-proxy:/sbin/nologin systemd-network:/sbin/nologin dbus:/sbin/nologin polkitd:/sbin/nologin abrt:/sbin/nologin tss:/sbin/nologin postfix:/sbin/nologin sshd:/sbin/nologin
8、显示/etc/passwd文件中默认登录shell为/bin/bash的用户;
[root@localhost home]# cut -d: -f1,7 /etc/passwd | grep "/bin/bash" root:/bin/bash baoman:/bin/bash hadoop:/bin/bash
9、找出/etc/passwd文件中的一位数两位数;
[root@localhost home]# grep "\<[0-9]\{1,2\}\>" /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
10、显示/boot/grub/grub.conf中至少一个空白字符开头的行;
[root@localhost grub2]# egrep "^[[:space:]]+" /boot/grub2/grub.cfg
11、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;
[root@localhost grub2]# egrep "^#[[:space:]]+[^[:space:]]+" /boot/grub2/grub.cfg # DO NOT EDIT THIS FILE# It is automatically generated by grub2-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # Fallback normal timeout code in case the timeout_style feature is# unavailable. # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change# the 'exec tail' line above.
12、打出netstat -ant命令结果中以'LISTEN',后或跟空白字符结尾的行;
[root@localhost grub2]# 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 tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN
13、添加用户bash,testbash,basher,nologin(此一个用户shell为/sbin/nologin),而后找出当前系统上用户名和默认shell相同的用户的信息;
[root@localhost scripts]# 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:1002:1002::/home/bash:/bin/bash nologin:x:1005:1005::/home/nologin:/sbin/nologin
原创文章,作者:jbm,如若转载,请注明出处:http://www.178linux.com/51989
评论列表(1条)
很不错,学有余力的话,可以把一些题目换个正则表达式来完成,加油。