1 / 13

System Administration HW3 - Shell Script

System Administration HW3 - Shell Script. chenyp. Requirements. File statistics (20%+10%) use one-line command to show files statistics Bonus(10%) script (20%) Write a shell script to parse log. A simple search platform (60%). File statistics.

len-horn
Download Presentation

System Administration HW3 - Shell Script

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. System Administration HW3- Shell Script chenyp

  2. Requirements • File statistics (20%+10%) • use one-line command to show files statistics • Bonus(10%) • script (20%) • Write a shell script to parse log. • A simple search platform (60%)

  3. File statistics • Use one-line command to show File statistics. • Print the sum of files’ size in the directory, find the largest and the smallest files, and print its filenames, filesizes and owners. (not include subdirectories) • All commands should be concatenated using "|"(pipe) in one line. • Can not create temporary file. • If the number of the largest or the smallest is more than one, choose the last one. • No “&&” “||” “>” “>>” “<“ .

  4. File statistics • Examples: • % ls –l • -rw-r--r-- 1 chenyp gcs 720 Nov 14 18:25 test • -rw-r--r-- 1 chenyp gcs 720 Nov 14 16:55 test_a • -rw-r--r-- 1 chenyp gcs 378 Nov 10 17:12 test_b • -rw-r--r-- 1 chenyp gcs 397 Nov 13 16:59 test_c • -rw-r--r-- 1 chenyp gcs 536 Nov 12 17:43 test_d • -rw-r--r-- 1 chenyp gcs 191 Nov 14 17:25 test_e • % ./hw3_1.sh • Bonus(10%) • If you can do it with subdirectories, you will get extra 10%.

  5. script • Write a script to parse log for ssh bruteforce. • Print the IP address and times descending. • Syntax • Parserlog.sh [-n number] –f file • -n • Show the most Nth times and its ip address. • If n is none, show all and sorted by times descending. • -f • Log file • Sample file: • http://nasa.cs.nctu.edu.tw/logfile

  6. script • SSH bruteforce Only parse these three formats Nov 15 13:53:32 NASA sshd[12397]: Invalid user supporte from 84.73.134.84 Nov 15 13:53:35 NASA sshd[12399]: Invalid user soporte from 84.73.134.84 Nov 15 21:45:25 NASA sshd[16601]: error: PAM: authentication error for root from 122.229.6.189 Nov 15 22:00:36 NASA sshd[16765]: error: PAM: authentication error for root from 115.186.131.106 Nov 15 22:16:40 NASA sshd[16868]: error: PAM: authentication error for root from 67.206.169.146 Nov 15 22:31:59 NASA sshd[16964]: error: PAM: authentication error for root from 74.238.205.245 Nov 15 22:47:22 NASA sshd[17129]: error: PAM: authentication error for root from 70.247.71.201 Nov 15 16:28:15 bsd1 sshd[6587]: error: PAM: authentication error for illegal user onlyeric23 from 140.113.246.1 • Example • % Parserlog.sh –n 3 –f /tmp/logfile • 70.247.71.201 7 times • 82.207.96.161 6 times • 208.124.238.246 5 times • 115.186.131.106 5 times • 140.113.47.207 5 times • 95.155.122.12 5 times

  7. A simple search platform • Write a user-friendly search platform by using dialog(1) • First, you should show a welcome message.

  8. A simple search platform • Second, you should use menubox for client to choose which service to provide.

  9. A simple search platform • Basic search: • Input a keyword. • Go to the wiki and show the first introduction for the keyword.

  10. A simple search platform • Advanced search: • Input a keyword. • Show the content for the keyword and use checklist to choose which information to display.

  11. A simple search platform • Mergedata • Input a keyword. • Show the content for the keyword and use checklist to choose which information to merge. • You should merge files to the wikimerge/keyword.tar.bz2 • The keyword.tar.bz2 contains the files client chosen. • Java.tar.bz2 contains • geography.txt • history.txt • Notes.txt • Externel_links.txt

  12. A simple search platform • Show mergedata • First, you should display which files in the wikimerge/ and use menubox for client to choose. • And show all the content in the keyword.tar.bz2. • Example: • You should display the content of the • geography.txt • history.txt • Notes.txt • Externel_links.txt • If you choose the java.tar.bz2.

  13. Help IRC channel #nctuNASA on freenode Newsgroup cs.course.sysadmin BBS bs2.to board CS-SysAdmin Email ta@nasa.cs.nctu.edu.tw Goto CSCC to ask professional 3F!

More Related