SHELL System File Integrity check

Source: Internet
Author: User

System Integrity Audit Tool

The shell script is as follows:

The #!/bin/bash##  variable is first declared to use shopt -s -o nounset#  declaration #  build Date date=$ (date + '%Y%m%d%H %m%s ') #  join the approved directory           #Dirs = "/bin /sbin /usr/bin  /usr/sbin /lib /usr/local/sbin /usr/local/bin /usr/local/lib "#  temp file                  #TMP_file =$ (mktemp /tmp/ Check. XXXXXX) #  File checksum store file fp= "/root/fp. $Date. Chksum" #  What kind of checksum tool checker= "/usr/bin/md5sum," find= "/usr /bin/find "#  function area                   #scan_file ()  {        local f         for f in  $Dirs         do                  $Find   $f  - type f >>  $TMP _file        done}#  Read the file to establish the checksum value for each file Cr_checksum_list ()  {        local f         if [ -f  $TMP _file ]; then                 for f in $ ( cat  $TMP _file);                         do                                   $Checker   $f  >>  $FP                  done         fi}rmtmp ()  {        [ -f  $TMP _file ] && rm -rf  $TMP _file}#   Main program Area #  scan list scan_file#  Establish checksum value of the file cr_checksum_list#  clean up temporary files rmtmp

Script execution:

[Email protected] ~]# sh my_filecheck.sh

To verify:

Md5sum-c Fp.20141205160628.chksum

If all OK, will show the word OK, if there is a problem, report the corresponding error, as follows:

[Email protected] ~]# Md5sum-c fp.20141205160628.chksum | Grep-v "OK" md5sum:/usr/bin/chattr:no such file or directory/usr/bin/chattr:failed Open or readmd5sum:warning:1 of 82 Listed files could not be read

This article is from the "Sword Slave" blog, be sure to keep this source http://diudiu.blog.51cto.com/6371183/1586734

SHELL System File Integrity check

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.