【Mage作業】linux運維實戰練習案例-2015年12月20日-12月31日(第一次)
阿新 • • 發佈:2020-10-09
1、建立一個10G的檔案系統,型別為ext4,要求開機可自動掛載至單獨資料/data目錄;
#選擇檔案系統分割槽所處的磁碟 #檢查磁碟中是否有足夠大的空間用於建立10G的檔案系統分割槽 fdisk-l;
#建立分割槽 fdisk/dev/sdb N 1 +10G W
#格式化並獲取UUID mkfs.ext4/dev/sdb1 blkid/dev/sdb1
#建立掛載目錄/data #寫入/etc/fstab用於開機自動掛載 mkdir/data echo"UUID=010146af-4e90-4be0-81c1-e60445225804/dataext4defaults00">>/etc/fstab mount-a mount
2、顯示`netstat -tan`命令結果中以‘LISTEN’後跟0個、1個或者多個空白字元結尾的行;
netstat-tan netstat-tan|grep-e"\<LISTEN\>[[:space:]]*$"
3、新增使用者nginx、zabbix、tomcat以及hadoop使用者(nologin使用者的shell為/sbin/nologin);而後找出/etc/passwd檔案中使用者名稱與其shell名相同的行;
useraddnginx;useraddzabbix;useraddtomcat;useraddhadoop;useraddnologin-s/sbin/nologin; cat/etc/passwd|grep"^\([[:alnum:]]\+\>\).*\1$"
4、找出/etc/rc.d/init.d/functions檔案中某單詞(單詞中間可以存在下劃線)後面跟著一組小括號的行;
cat/etc/rc.d/init.d/functions|egrep"\<[[:alpha:]]+_[[:alpha:]]+\>\(\)"
5、使用echo輸出一個路徑,而後egrep找出其路徑基名;進一步的使用egrep取出其目錄名(注意是目錄名,而非目錄路徑);
echo"/abc/def/ghi/jkl/"|egrep-o"[^/]+/?$"|cut-d"/"-f1
6、查詢/usr目錄下不屬於root、bin或hadoop的所有檔案;
find/usr-!\(-userroot-o-userbin-o-userhadoop\)-ls
7、某天系統被***了,***在你係統下留下***檔案:
現需要查詢當前系統上沒有屬主或屬組,且最近一週內曾被訪問過的所有檔案;
另外,需要查詢/etc目錄下大於20k且型別為普通檔案的所有檔案;
find/-nouser-o-nogroup-atime-7 find/etc-typef-size+20k
8、建立目錄/test/data,讓某組內普通使用者對其有寫許可權,且建立的所有檔案的屬組為目錄所屬的組;此外,每個使用者僅能刪除自己的檔案。
[[email protected]~]#mkdir-p/test/data [[email protected]~]#groupaddtestgroup [[email protected]~]#chown:testgroup/test/data/ [[email protected]~]#chmodg+w/test/data/ [[email protected]~]#chmodg+s/test/data/ [[email protected]~]#chmodo+t/test/data/ [[email protected]~]#ll-d/test/data/
轉載於:https://blog.51cto.com/978543210/1730192