1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其他用户均没有任何访问权限。
1. [root@jizo etc]# ls –d skel
2. skel
3. [root@jizo etc]# cd /home
4. [root@jizo home]# ls
5. jizo
6. [root@jizo home]# cp –r /etc/skel/ /home/tuser1 | chmod –R g=,o= /home/tuser1
7. [root@jizo home]# ll
8. total 4
9. drwx——. 16 jizo jizo 4096 Dec 26 01:33 jizo
10. drwx——. 3 root root 87 Dec 26 02:01 tuser1
11. [root@jizo tuser1]# ls -al
total 16
drwx——. 3 root root 87 Dec 26 02:01 .
drwxr-xr-x. 4 root root 30 Dec 26 02:01 ..
-rw——-. 1 root root 18 Dec 26 02:01 .bash_logout
-rw——-. 1 root root 193 Dec 26 02:01 .bash_profile
-rw——-. 1 root root 231 Dec 26 02:01 .bashrc
-rw——-. 1 root root 334 Dec 26 02:01 .emacs
drwx——. 4 root root 37 Dec 26 02:01 .mozilla
12.
13.
2、编辑/etc/group文件,添加组hadoop
1. [root@jizo ~]# vim /etc/group
2.
3. libstoragemgmt:x:988:
4. geoclue:x:987:
5. memcached:x:986:
6. rpc:x:32:
7. setroubleshoot:x:985:
8. rtkit:x:172:
9. ntp:x:38:
10. kvm:x:36:qemu
11. qemu:x:107:
12. named:x:25:
13. rpcuser:x:29:
14. nfsnobody:x:65534:
15. radvd:x:75:
16. chrony:x:984:
17. pcp:x:983:
18. pulse–access:x:982:
19. pulse–rt:x:981:
20. pulse:x:171:
21. hsqldb:x:96:
22. tomcat:x:91:
23. pkiuser:x:17:
24. gdm:x:42:
25. gnome–initial–setup:x:980:
26. mysql:x:27:
27. avahi:x:70:
28. slocate:x:21:
29. postgres:x:26:
30. sshd:x:74:
31. dovecot:x:97:
32. dovenull:x:979:
33. oprofile:x:16:
34. tcpdump:x:72:
35. jizo:x:1000:jizo
36. hadoop:x:5003: #新插入
37. [root@jizo ~]# tail -l /etc/group
slocate:x:21:
postgres:x:26:
sshd:x:74:
dovecot:x:97:
dovenull:x:979:
oprofile:x:16:
tcpdump:x:72:
jizo:x:1000:jizo
hadoop:x:5003: #新插入
38.
39.
3、手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组id为hadoop组的id号;其家目录为/home/hadoop
1. [root@jizo ~]# tail –l /etc/passwd
2. mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
3. avahi:x:70:70:Avahi mDNS/DNS–SD Stack:/var/run/avahi–daemon:/sbin/nologin
4. postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
5. sshd:x:74:74:Privilege–separated SSH:/var/empty/sshd:/sbin/nologin
6. dovecot:x:97:97:Dovecot IMAP server:/usr/libexec/dovecot:/sbin/nologin
7. dovenull:x:984:979:Dovecot's unauthorized user:/usr/libexec/dovecot:/sbin/nologin
8. oprofile:x:16:16:Special user account to be used by OProfile:/var/lib/oprofile:/sbin/nologin
9. tcpdump:x:72:72::/:/sbin/nologin
10. jizo:x:1000:1000:jizo:/home/jizo:/bin/bash
11. hadoop:x:5003:5005::/home/hadoop:/bin/bash #新插入
4、复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其它用户没有任何访问权限
1. [root@jizo ~]# cp –r /etc/skel/ /home/hadoop | chmod –R g=,o= /home/hadoop/
2. [root@jizo ~]# ls –al /home/hadoop
3. total 16
4. drwx——. 3 root root 87 Dec 26 02:54 .
5. drwxr–xr–x. 5 root root 43 Dec 26 02:52 ..
6. –rw——-. 1 root root 18 Dec 26 02:52 .bash_logout
7. –rw——-. 1 root root 193 Dec 26 02:52 .bash_profile
8. –rw——-. 1 root root 231 Dec 26 02:52 .bashrc
9. –rw——-. 1 root root 334 Dec 26 02:52 .emacs
10. drwx——. 4 root root 37 Dec 26 02:52 .mozilla
11. [root@jizo ~]# ls –al /etc/skel
12. total 32
13. drwxr–xr–x. 3 root root 87 Dec 26 00:39 .
14. drwxr–xr–x. 166 root root 12288 Dec 26 02:49 ..
15. –rw–r—r–. 1 root root 18 Nov 20 2015 .bash_logout
16. –rw–r—r–. 1 root root 193 Nov 20 2015 .bash_profile
17. –rw–r—r–. 1 root root 231 Nov 20 2015 .bashrc
18. –rw–r—r–. 1 root root 334 Oct 7 2015 .emacs
19. drwxr–xr–x. 4 root root 37 Dec 26 00:16 .mozilla
5、修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop
1. [root@jizo ~]# chown –R hadoop:hadoop /home/hadoop/
2. [root@jizo ~]# ls –l /home
3. total 4
4. drwx——. 3 hadoop hadoop 87 Dec 26 02:54 hadoop
5. drwx——. 16 jizo jizo 4096 Dec 26 01:33 jizo
6. drwx——. 3 root root 87 Dec 26 02:01 tuser1
7. [root@jizo ~]# ls –al /home/hadoop
8. total 16
9. drwx——. 3 hadoop hadoop 87 Dec 26 02:54 .
10. drwxr–xr–x. 5 root root 43 Dec 26 02:52 ..
11. –rw——-. 1 hadoop hadoop 18 Dec 26 02:52 .bash_logout
12. –rw——-. 1 hadoop hadoop 193 Dec 26 02:52 .bash_profile
13. –rw——-. 1 hadoop hadoop 231 Dec 26 02:52 .bashrc
14. –rw——-. 1 hadoop hadoop 334 Dec 26 02:52 .emacs
15. drwx——. 4 hadoop hadoop 37 Dec 26 02:52 .mozilla
6、显示/proc/meminfo文件中以大写或小写s开头的行;用两种方式
1. [root@jizo ~]# grep "^[sS]" /proc/meminfo
2. SwapCached: 928 kB
3. SwapTotal: 2097148 kB
4. SwapFree: 2075564 kB
5. Shmem: 3724 kB
6. Slab: 287972 kB
7. SReclaimable: 201020 kB
8. SUnreclaim: 86952 kB
1. [root@jizo ~]# grep –i "^s" /proc/meminfo
2. SwapCached: 928 kB
3. SwapTotal: 2097148 kB
4. SwapFree: 2075564 kB
5. Shmem: 3724 kB
6. Slab: 287972 kBc
7. SReclaimable: 201020 kB
8. SUnreclaim: 86952 kB
7、显示/etc/passwd文件中默认shell为非/sbin/nologin的用户
1. [root@jizo /]# grep –v "/sbin/nologin" /etc/passwd
2. root:x:0:0:root:/root:/bin/bash
3. sync:x:5:0:sync:/sbin:/bin/sync
4. shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
5. halt:x:7:0:halt:/sbin:/sbin/halt
6. amandabackup:x:33:6:Amanda user:/var/lib/amanda:/bin/bash
7. tomcat:x:91:91:Apache Tomcat:/usr/share/tomcat:/bin/nologin
8. postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
9. jizo:x:1000:1000:jizo:/home/jizo:/bin/bash
10. hadoop:x:5003:5005::/home/hadoop:/bin/bash #新插入
8、显示/etc/passwd文件中其默认shell为/bin/bash的用户
1. [root@jizo /]# grep "/bin/bash" /etc/passwd
2. root:x:0:0:root:/root:/bin/bash
3. amandabackup:x:33:6:Amanda user:/var/lib/amanda:/bin/bash
4. postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
5. jizo:x:1000:1000:jizo:/home/jizo:/bin/bash
6. hadoop:x:5003:5005::/home/hadoop:/bin/bash #新插入
9、找出/etc/passwd文件中的一位数或两位数
1. [root@jizo /]# grep –o "\<[0-9]\{1,2\}\>" /etc/passwd | sort –n
2. 0
3. 0
4. 0
5. 0
6. 0
7. 0
8. 1
9. 1
10. 2
11. 2
12. 3
13. 4
14. 4
15. 5
16. 6
17. 6
18. 7
19. 7
20. 8
21. 11
22. 12
23. 12
24. 14
25. 16
26. 16
27. 17
28. 17
29. 25
30. 25
31. 26
32. 26
33. 27
34. 27
35. 29
36. 29
37. 32
38. 32
39. 33
40. 38
41. 38
42. 42
43. 42
44. 48
45. 48
46. 50
47. 59
48. 59
49. 65
50. 66
51. 70
52. 70
53. 72
54. 72
55. 74
56. 74
57. 75
58. 75
59. 76
60. 81
61. 81
62. 89
63. 89
64. 91
65. 91
66. 96
67. 96
68. 97
69. 97
70. 99
71. 99
10、显示/boot/grub/grub.conf中以至少一个空白字符开头的行
1. [root@jizo boot]# grep "^[[:space:]]\+" /boot/grub/grub.conf
11、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又至少一个非空白字符的行
1. [root@jizo boot]# grep "^#[[:space:]]\+[[:graph:]]\+" /etc/rc.d/rc.sysinit
12、打出netstat -tan命令执行结果中以‘LISTEN’跟0、1或多个空白字符结尾的行
1. [root@jizo boot]# netstat –ant | grep 'LISTEN[[:space:]]* '
2. tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
3. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
4. tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
5. tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
6. tcp6 0 0 :::22 :::* LISTEN
7. tcp6 0 0 ::1:631 :::* LISTEN
8. tcp6 0 0 ::1:25 :::* LISTEN
13、添加用户bash,testbash,basher,nologin(此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户信息
1. [root@jizo boot]# grep '^\(.*\):.*\1$' /etc/passwd
2. sync:x:5:0:sync:/sbin:/bin/sync
3. shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
4. halt:x:7:0:halt:/sbin:/sbin/halt
原创文章,作者:jindizang,如若转载,请注明出处:http://www.178linux.com/64849
评论列表(1条)
是编辑器出了问题了?看着不知所云。