国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 操作系統(tǒng) > 正文

監(jiān)視/etc/passwd文件是否正常

2024-06-28 13:24:58
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
監(jiān)視/etc/passwd文件是否正常

幫助監(jiān)視/etc/passwd文件是否正常(P90 練習(xí)6.7)

1)找出有UID0的所有項(xiàng)

2)找出有重復(fù)UID的所有項(xiàng)

3)找出有重復(fù)登錄名的所有項(xiàng)

4)找出沒有口令的所有項(xiàng)

5)找出沒有作廢日期的所有項(xiàng)

以下是實(shí)現(xiàn)的shell腳本:

#!/bin/bash#監(jiān)視/etc/passwd正常

#找出有UID 0的用戶echo "----------------------------------"user1=`less /etc/passwd | awk -F: '$3==0 {PRint $1}'`if [ -z $user1 ];then echo "1.there is no user's UID equals 0"elseecho -n "1.the user of UID equals 0 have: "$user1echo ""fi

#找出有重復(fù)UID的用戶echo "----------------------------------"user2=`awk -F: 'BEGIN{ORS=","}NR==FNR {a[$3]++} NR>FNR&&a[$3]>1 {print $1,$3}' /etc/passwd /etc/passwd`if [ -z $user2 ];then echo "2.there is no user's UID repeat"elseecho -n "2.the user of repeat UID have: "$user2echo ""fi

#找出有重復(fù)登錄名的用戶echo "---------------------------------"user3=`awk -F: 'BEGIN{ORS=","}NR==FNR {a[$1]++} NR>FNR&&a[$1]>1 {print $1,$3}' /etc/passwd /etc/passwd`if [ -z $user3 ];then echo "3.there is no user's login name repeat"elseecho -n "3.the user of repeat login name have: "$user3echo ""fi

#找出沒有口令的所有用戶echo "---------------------------------"user4=`sudo awk -F: 'BEGIN{ORS=","} length($2)<30 {print $1}' /etc/shadow`if [ -z $user4 ];then echo "4.there is no user have no passWord"elseecho -n "4.the user of no password have: "$user4echo ""fi

#找出沒有作廢日期的所有用戶echo "---------------------------------"user5=`sudo awk -F: 'BEGIN{ORS=","} length($7)<1 {print $1}' /etc/shadow`if [ -z $user5 ];then echo "5.there is no user have no outdate time"elseecho -n "5.the user of no outdate time have: "$user5echo ""fiecho "---------------------------------"


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 民丰县| 西藏| 安阳县| 翼城县| 福海县| 阿鲁科尔沁旗| 徐闻县| 巴东县| 温宿县| 峨山| 泽库县| 临清市| 阳高县| 垣曲县| 祁门县| 海安县| 乌鲁木齐市| 长武县| 明水县| 伊通| 景宁| 山阴县| 荥经县| 基隆市| 集贤县| 独山县| 台北县| 合阳县| 宜川县| 资源县| 江油市| 沙湾县| 修文县| 丹棱县| 井冈山市| 正镶白旗| 罗山县| 双峰县| 社会| 泗洪县| 峡江县|