1、復制 /etc/skel 目錄為 /home/tuser1,要求 /home/tuser1及其內部文件的屬組和其他用戶均沒有任何訪問權限。
[root@localhost ~]# cp -r /etc/skel /home/tuser1 && chmod -R g-r,o-r /home/tuser1
(1)使用cp命令的-r選項,將/etc/skel目錄及其所有內容復制到/home/tuser1中,并更名為tuser1,
(2)使用邏輯運算符 && 形成“與”條件,即完成復制后,再執行后面的代碼塊,如果第一個代碼塊,寫錯,后面的內容也就不會執行,當然我不會寫錯的,呵呵呵
(3)使用chmod命令進行進行相關權限操作,其中使用-R,對/home/tuser1目錄以及所包含的所有內容,進行權限更改;使用g-r,去掉操作域中屬組的訪問權限,o-r,同理。
2、編輯/etc/group文件,添加組 hadoop。
(1)使用輸出重定向實現,追加輸出(這樣操作后,如想 su 到hadoop下,需要為其的家目錄手動添加 .bash_history等文件)
[root@localhost ~]# echo "hadoop:x:2013:" >> /etc/group
(2)使用vim等編輯工具(這樣操作后,如想 su 到hadoop下,需要為其的家目錄手動添加 .bash_history等文件)
3、手動編輯/etc/passwd文件新增一行,添加用戶hadoop,其基本組ID為hadoop組的id號;其家目錄為/home/hadoop。
(1)使用輸出重定向實現,追加輸出(這樣操作后,如想 su 到hadoop下,需要為其的家目錄手動添加 .bash_history等文件)
[root@localhost ~]# echo "hadoop:x:3006:2013::/home/hadoop:/bin/bash" >> /etc/passwd
(2)使用vim等編輯工具(這樣操作后,如想 su 到hadoop下,需要為其的家目錄手動添加 .bash_history等文件)
4、復制 /etc/skel 目錄為/home/hadoop,要求修改hadoop目錄的屬組和其它用戶沒有任何訪問權限。
[root@localhost ~]# cp -r /etc/skel/ /home/hadoop/ && chmod g-r,o-r /home/hadoop/
5、修改/home/hadoop目錄及其內部所有文件的屬主為hadoop,屬組為hadoop。
[root@localhost ~]# chown -R hadoop:hadoop /home/hadoop
6、顯示/proc/meminfo文件中以大寫或小寫S開頭的行;用兩種方式;
[root@localhost ~]# cut -d' ' -f1 /proc/meminfo | egrep -i "^s"
[root@localhost ~]# cut -d' ' -f1 /proc/meminfo | egrep "^[sS]"
7、顯示/etc/passwd文件中其默認shell為非/sbin/nologin的用戶;
[root@localhost ~]# cut -d: -f1,7 /etc/passwd | egrep "[^/sbin/nologin]$"
8、顯示/etc/passwd文件中其默認shell為/bin/bash的用戶;
[root@localhost ~]# cut -d: -f1,7 /etc/passwd | egrep "/bin/bash$"
9、找出/etc/passwd文件中的一位數或兩位數;
[root@localhost ~]# cut -d: -f3,4 /etc/passwd | egrep "\<[0-9]{1,2}\>"
10、顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行;
[root@localhost ~]# cat /boot/grub/grub.conf | egrep "^[[:space:]]+.*"
11、顯示/etc/rc.d/rc.sysinit文件中以#開頭,后面跟至少一個空白字符,而后又有至少一個非空白字符的行;
[root@localhost ~]# cat /etc/rc.d/rc.sysinit | egrep "^#[[:space:]]+[^[:space:]]+"
12、打出netstat -tan命令執行結果中以‘LISTEN’,后或跟空白字符結尾的行;
[root@localhost ~]# netstat -tan | egrep "LISTEN[[:space:]]+"
13、添加用戶bash,testbash,basher,nologin(此一個用戶的shell為/sbin/nologin),而后找出當前系統上其用戶名和默認shell相同的用戶的信息;
[root@localhost ~]# egrep -o "^([^:]+\>).*\1$" /etc/passwd
原創文章,作者:hotpoint,如若轉載,請注明出處:http://www.www58058.com/50363