In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use shell script to achieve linux system file integrity test". In daily operation, I believe that many people have doubts about how to use shell script to achieve linux system file integrity test. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the question of "how to use shell script to achieve linux system file integrity detection". Next, please follow the editor to study!
Content of the script:
The code is as follows:
Cat my_filecheck.sh
#! / bin/bash
#
# variables must be declared before they can be used
Shopt-s-o nounset
# Declaration
# date of establishment
Date=$ (date +'% Y% m% d% H% M% S')
# add the directory to the audit #
Dirs= "/ bin / sbin / usr/bin / usr/sbin / lib / usr/local/sbin / usr/local/bin / usr/local/lib"
# temporary files #
TMP_file=$ (mktemp / tmp/check.XXXXXX)
# File checksum Storage File
FP= "/ root/fp.$Date.chksum"
# which checksum tool to use
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 files and establish checksum values 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
# create the checksum value of the file
Cr_checksum_list
# cleaning up temporary files
RmTMP
Execute the script:
The code is as follows:
. / my_filecheck.sh
To verify:
The code is as follows:
Md5sum-c fp.20141205160628.chksum
The code is as follows:
Md5sum-c fp.20141209202544.chksum
/ bin/gawk: OK
/ bin/igawk: OK
/ bin/ln: OK
/ bin/loadkeys: OK
/ bin/gzip: OK
/ bin/mkdir: OK
/ bin/date: OK
/ bin/cat: OK
/ bin/mountpoint: OK
/ bin/taskset: OK
/ bin/umount: OK
/ bin/mount: OK
/ bin/doexec: OK
/ bin/kill: OK
/ bin/sync: OK
/ bin/unicode_start: OK
/ bin/usleep: OK
/ bin/mknod: OK
/ bin/setserial: OK
/ bin/cp: OK
/ bin/mktemp: OK
/ bin/setfont: OK
/ bin/unicode_stop: OK
.
/ lib/modules/2.6.18-194.el5PAE/kernel/crypto/cast5.ko: OK
/ lib/modules/2.6.18-194.el5PAE/kernel/crypto/crypto_blkcipher.ko: OK
/ lib/modules/2.6.18-194.el5PAE/kernel/crypto/twofish.ko: OK
/ lib/modules/2.6.18-194.el5PAE/kernel/crypto/authenc.ko: OK
/ lib/modules/2.6.18-194.el5PAE/kernel/crypto/cbc.ko: OK
/ lib/modules/2.6.18-194.el5PAE/kernel/crypto/crypto_hash.ko: OK
/ lib/modules/2.6.18-194.el5PAE/kernel/crypto/seqiv.ko: OK
/ lib/libproc-3.2.7.so: OK
/ lib/libacl.so.1.1.0: OK
/ lib/libauparse.so.0.0.0: OK
/ lib/libdmraid.so.1.0.0.rc13-17: OK
/ lib/libvolume_id.so.0.66.0: OK
/ lib/libgobject-2.0.so.0.1200.3: OK
/ lib/libnss_compat-2.5.so: OK
/ lib/rtkaio/i686/nosegneg/librtkaio-2.5.so: OK
/ lib/rtkaio/librtkaio-2.5.so: OK
/ lib/libdmraid-events-isw.so.1.0.0.rc13: OK
/ lib/libdevmapper-event-lvm2snapshot.so.2.02: OK
/ lib/libblkid.so.1.0: OK
/ lib/libdb-4.3.so: OK
/ lib/libSegFault.so: OK
/ lib/libiw.so.28: OK
/ lib/libdmraid-events-isw.so.1.0.0.rc13-17: OK
You can see a lot of OK.
If you only want to see errors, you can use the following command:
The code is as follows:
Md5sum-c fp.20141209202544.chksum | grep-v "OK"
At this point, the study on "how to use shell scripts to achieve linux system file integrity testing" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.