Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Script for testing changes in system directory
- =============================================================================================
- crontab function : (performs the script every 30 mins) 00,30 * * * * Script path
- ---------------------------------------------------------------------------------------------
- #Part A : Create a script to detect and log changes to /etc/passwd
- # Part 1 - The number of users in the system may increase or decrease.
- # Part 2 - One or more characters in the file may change.
- ---------------------------------------------------------------------------------------------
- Part 1 ~ The number of users may change
- ---------------------------------------------------------------------------------------------
- 1. ) CREATED A copy , "compare" , of /etc/passwd to compare with
- ~ located at /home/kwblanchard/bin/logs/compare
- 2. ) Compares the wc-l of the two files
- ~ diff <(wc-l < /etc/passwd) <(wc-l < /home/kwblanchard/bin/logs/compare)
- - diff -y --suppress-common-lines /etc/passwd /home/kwblanchard/bin/logs/compare | grep '^' ??? | wc -l
- 3. ) Create an if statement
- ~ How to create if statements?
- - If there is no difference, echo "There is no difference between the two files"
- - If there is a difference , echo " There is a difference between the two files"
- - show the results of the diff command
- - create a log file of the difference
- 4. ) Put at end of script to rewrite the "compare" file with the up to date version of /etc/passwd
- ~ cp -r /etc/passwd /home/kwblanchard/bin/logs/compare
- ---------------------------------------------------------------------------------------------
- Part 2 ~ One or more characters in the file may change
- ---------------------------------------------------------------------------------------------
- 1. ) CREATED A copy , "compare" , of /etc/passwd to compare with
- ~ located at /home/kwblanchard/bin/logs/compare
- 2. ) Log the date and time then the word count of the file.
- ~ wc -w < etc/passwd
- - how to write this to a file?
- TIME: echo %time% > logfile.txt
- DATE: echo %date% > logfile.txt
- 3. ) Log the date and time then the MD5 sum of the file.
- ~ Stated above for date and time
- ~ sha1sum /etc/passwd > logfile.txt
- 4. ) Save the date and time then the entire password file.
- ~ cp -r /etc/passwd /home/kwblanchard/bin/logs/compare
- ---------------------------------------------------------------------------------------------
- =============================================================================================
- ---------------------------------------------------------------------------------------------
- #Part B : Detect the changes to the volume size of /home2
- # - Minimum change in size will be 100MB. Smaller changes can be ignored.
- ---------------------------------------------------------------------------------------------
- 1. ) Create a copy , "Comparable", of the /home2 directory to compare to
- 2. ) Compare each file in the current /home2 directory to the back up
- - use an if statement that uses each files size as its true / false parameter. ( over 100mb = true)
- - create another comparable file of the total size of the directory to see if there are any changes at all.
- use as first if statement and if true continue onto the individual changes.
- ---------------------------------------------------------------------------------------------
- =============================================================================================
- ---------------------------------------------------------------------------------------------
- #Part C : Detect changes to the startup files
- # - A new file may be added to the directory
- # - Something may make a change in an existing file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement