1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。
~]# cp -r /etc/skel /home/tuser1; chmod -R gx=--- /home/tuser1 [root@magelinux ~]# ls -la /home/tuser1/ total 28 drwx------. 2 root root 4096 Jul 28 08:52 . drwxr-xr-x. 5 root root 4096 Jul 28 09:57 .. -rw-------. 1 root root 18 Jul 28 08:52 .bash_logout -rw-------. 1 root root 176 Jul 28 08:52 .bash_profile -rw-------. 1 root root 124 Jul 28 08:52 .bashrc -rw-------. 1 root root 171 Jul 28 08:52 .kshrc -rw-------. 1 root root 658 Jul 28 08:52 .zshrc
2、編輯/etc/group文件,添加組hadoop。
~]# cat >>/etc/group <<EOF > hadoop:x:3000: > EOF ~]# tail -1 /etc/group hadoop:x:3000:
3、手動編輯/etc/passwd文件新增一行,添加用戶hadoop,其基本組ID為hadoop組的id號;其家目錄為/home/hadoop。
[root@magelinux ~]# cat >>/etc/passwd <<EOF > hadoop:x:3000:3000::/home/hadoop:/bin/bash > EOF
4.復制/etc/skel目錄為/home/hadoop,要求修改hadoop目錄的屬組和其它用戶沒有任何訪問權限。
[root@magelinux ~]# cp -r /etc/skel/ /home/hadoop ; chmod go=--- /home/hadoop [root@magelinux ~]# ls -ld /home/hadoop/ drwx------. 2 root root 4096 Jul 28 09:57 /home/hadoop/
5、修改/home/hadoop目錄及其內部所有文件的屬主為hadoop,屬組為hadoop。
[root@magelinux ~]# chown -R hadoop:hadoop /home/hadoop/ [root@magelinux hadoop]# ls -la /home/hadoop/ total 28 drwx------. 2 hadoop hadoop 4096 Jul 28 09:57 . drwxr-xr-x. 5 root root 4096 Jul 28 09:57 .. -rw-r--r--. 1 hadoop hadoop 18 Jul 28 09:57 .bash_logout -rw-r--r--. 1 hadoop hadoop 176 Jul 28 09:57 .bash_profile -rw-r--r--. 1 hadoop hadoop 124 Jul 28 09:57 .bashrc -rw-r--r--. 1 hadoop hadoop 171 Jul 28 09:57 .kshrc -rw-r--r--. 1 hadoop hadoop 658 Jul 28 09:57 .zshrc
6、顯示/proc/meminfo文件中以大寫或小寫S開頭的行;用兩種方式;
[root@magelinux ~]# grep ^[sS] /proc/meminfo SwapCached: 0 kB SwapTotal: 2047996 kB [root@magelinux ~]# grep -i ^s /proc/meminfo SwapCached: 0 kB SwapTotal: 2047996 kB
7、顯示/etc/passwd文件中其默認shell為非/sbin/nologin的用戶;
[root@magelinux ~]# grep -v "/sbin/nologin" /etc/passwd root:x:0:0:root:/root:/bin/bash sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt gentoo:x:500:500::/home/gentoo:/bin/bash hadoop:x:3000:3000::/home/hadoop:/bin/bash
8、顯示/etc/passwd文件中其默認shell為/bin/bash的用戶
[root@magelinux ~]# grep "/bin/bash$" /etc/passwd | cut -d: -f1 root gentoo hadoop
9、找出/etc/passwd文件中的一位數或兩位數;
[root@magelinux ~]# egrep -o "\<[0-9]{1,2}\>" /etc/passwd
10、顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行;
[root@magelinux ~]# grep "^[[:space:]]" /boot/grub/grub.conf
11、顯示/etc/rc.d/rc.sysinit文件中以#開頭,后面跟至少一個空白字符,而后又有至少一個非空白字符的行
[root@magelinux ~]# egrep "^#[[:space:]]{1,}[^[:space:]]+" /etc/rc.d/rc.sysinit # /etc/rc.d/rc.sysinit - run once at boot time # Taken in part from Miquel van Smoorenburg's bcheckrc. # Check SELinux status
12、打出netstat -tan命令執行結果中以‘LISTEN’,后或跟空白字符結尾的行;
netstat -tan |egrep "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為/sbin/nologin),而后找出當前系統上其用戶名和默認shell相同的用戶的信息;
[root@magelinux ~]# egrep "^([[:alpha:]]+\>).*\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:3001:3001::/home/bash:/bin/bash nologin:x:3004:3004::/home/nologin:/sbin/nologin
14、顯示/proc/meminfo文件中以大寫或小寫S開頭的行;用三種方式;
[root@magelinux ~]# grep ^[sS] /proc/meminfo SwapCached: 0 kB SwapTotal: 2047996 kB SwapFree: 2047996 kB Shmem: 220 kB Slab: 156856 kB SReclaimable: 93320 kB SUnreclaim: 63536 kB [root@magelinux ~]# grep -i ^s /proc/meminfo SwapCached: 0 kB SwapTotal: 2047996 kB SwapFree: 2047996 kB Shmem: 220 kB Slab: 156836 kB SReclaimable: 93312 kB SUnreclaim: 63524 kB [root@magelinux ~]# egrep -i ^s /proc/meminfo SwapCached: 0 kB SwapTotal: 2047996 kB SwapFree: 2047996 kB Shmem: 220 kB Slab: 156840 kB SReclaimable: 93316 kB SUnreclaim: 63524 kB
15、顯示/etc/passwd文件中其默認shell為非/sbin/nologin的用戶;
[root@magelinux ~]# grep -v "/sbin/nologin$" /etc/passwd root:x:0:0:root:/root:/bin/bash sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt gentoo:x:500:500::/home/gentoo:/bin/bash hadoop:x:3000:3000::/home/hadoop:/bin/bash bash:x:3001:3001::/home/bash:/bin/bash testbash:x:3002:3002::/home/testbash:/bin/bash basher:x:3003:3003::/home/basher:/bin/bash
16、顯示/etc/passwd文件中其默認shell為/bin/bash的用戶;
[root@magelinux ~]# grep "/bin/bash$" /etc/passwd |cut -d: -f1 root gentoo hadoop bash testbash basher
17、找出/etc/passwd文件中的一位數或兩位數;
[root@magelinux ~]# egrep -o "\<[0-9]{1,2}\>" /etc/passwd 0 0
原創文章,作者:微,如若轉載,請注明出處:http://www.www58058.com/26811
寫的很好,排版也很棒,加油