# 利?SSH客戶端登錄 root 賬號,查看 /tmp ?錄下是否存在??錄 myshare,如果沒有則建?該?錄;
[root@wu1 ~]# mkdir /tmp/myshare
# 在 myshare ?錄下創建?個名為“學號”的?件夾和?個名為 exam2.txt 的?件;
[root@wu1 ~]# mkdir /tmp/myshare/201814090518
[root@wu1 ~]# touch /tmp/myshare/201814090518/exam2.txt
# 創建?個名字為 test 的新?戶,并指定uid為1024;
[root@wu1 ~]# useradd -u 1024 test
# 把 /etc/passwd 和 /etc/shadow 含有?戶 test 資訊的 ? 追加到 exam2.txt ?件中;
[root@wu1 ~]# cat /etc/passwd |grep test >> /tmp/myshare/201814090518/exam2.txt
[root@wu1 ~]# cat /etc/shadow |grep test >> /tmp/myshare/201814090518/exam2.txt
# 把 /etc/passwd 前13?的內容 追加到 myshare ?錄下 名為 exam2.txt 的?件中;
[root@wu1 ~]# head -n 13 /etc/passwd >> /tmp/myshare/201814090518/exam2.txt
# 把 myshare ?錄下的所有?件和??錄的內容以?格式的?式追加到 exam2.txt 中;
[root@wu1 ~]# ls -lR /tmp/myshare >> /tmp/myshare/201814090518/exam2.txt
# 把 myshare ?錄及其?錄下的所有?件和??錄的擁有者設定為?戶 test ,組改為mail;
[root@wu1 ~]# chown -R test /tmp/myshare
[root@wu1 ~]# chgrp -R mail /tmp/myshare
# 把 myshare ?錄下的所有?件和??錄的內容以?格式的?式追加到 exam2.txt 中;
[root@wu1 ~]# ls -lR /tmp/myshare >> /tmp/myshare/201814090518/exam2.txt
# 利?su命令切換到?戶 test 賬號;
[root@wu1 ~]# su test
# 進?/tmp/myshare/“學號”?錄,采?vi編輯器撰寫以下程式,程式名稱為hello.sh
[test@wu1 root]$ vi /tmp/myshare/201814090518/hello.sh
# 保存 hello.sh 后,給予 hello.sh 擁有者可讀、可寫和可執?的權限,同組可讀可執?,其他?可執?權限;
[test@wu1 root]$ chmod 751 /tmp/myshare/201814090518/hello.sh
# 以?格式的形式查看 hello.sh 的?件權限資訊,并把輸出內容追加到 exam2.txt;
[test@wu1 root]$ ll /tmp/myshare/201814090518/hello.sh >> /tmp/myshare/201814090518/exam2.txt
# 輸? ./hello.sh 執?腳本,查看輸出結果,并把輸出結果追加 exam2.txt;
[test@wu1 root]$ /tmp/myshare/201814090518/hello.sh >> /tmp/myshare/201814090518/exam2.txt
# 進??戶 test 的?戶主?錄,在這個?錄下創建 hello.sh 的軟鏈接myhello.sh,同時拷? hello.sh 到該?錄下并改名為 hello.sh.bak;
[test@wu1 root]$ cd /home/test
[test@wu1 ~]$ ln -s /tmp/myshare/201814090518/hello.sh /home/test/myhello.sh
[test@wu1 ~]$ cp /tmp/myshare/201814090518/hello.sh /home/test/hello.sh.bak
# 以?格式形式查看?戶 test 主?錄下的所有?件并把結果追加到 exam2.txt中;
[test@wu1 ~]$ ls -lR /home/test >> /tmp/myshare/201814090518/exam2.txt
# 執??戶 test 主?錄下的myhello.sh?件,查看鏈接是否正常;
[test@wu1 ~]$ /home/test/myhello.sh
# 退出?戶 test 帳號,回到root帳號
[test@wu1 ~]$ su root
# 以?格式形式查看?戶 test 主?錄下的所有?件(含隱藏?件)并把結果追加到 exam2.txt中;
[root@wu1 test]# ls -lRa /home/test >> /tmp/myshare/201814090518/exam2.txt
# 從 /usr 開始查找后綴名為.conf的所有?件(普通?件),把輸出結果追加到 exam2.txt中;
[root@wu1 test]# find /usr -name "*.conf" -type f >> /tmp/myshare/201814090518/exam2.txt
# 從上?步找到的conf?件中找出?件容量最?的?件,并把這個?件以?格式形式追加到exam2.txt 中 ;(倒引號)
[root@wu1 ~]# ls -lSh `find /usr -name "*.conf" -type f` | head -n 1 >> /tmp/myshare/201814090518/exam2.txt
# 統計出系統中有多少個?戶帳號,把數量追加到 exam2.txt 中;
[root@wu1 ~]# cat /etc/passwd | wc -l >> /tmp/myshare/201814090518/exam2.txt
# 把 exam2.txt ?件轉換為windows格式,
[root@wu1 ~]# unix2dos /tmp/myshare/201814090518/exam2.txt
# 洗掉?戶test 的所有內容(包括主?錄)
[root@wu1 ~]# userdel -r test
# 洗掉/tmp/myshare?錄
[root@wu1 ~]# rm -rf /tmp/myshare
參考
Linux——兩種方式查找指定后綴的檔案并輸出容量最大的檔案_JiaM-CSDN博客
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/274507.html
標籤:其他
上一篇:Frida框架逆向入門-第一篇
