如何比较系统修改前后的文件状态改变呢?比如新生成了哪些目录?哪些文件?又或者隐藏了什么?典型的情况就是安装一个应用后,到底这个应用有没有偷着干什么,那怎么看呢?对Mac OS 系统文件目录分别生成树状结构,遍历文件,然后再diff比较。
Current_Time=`date +%Y%m%d%H%M`
sudo ls / >> dir${Current_Time}.txt
sudo tree /Users >> users${Current_Time}.txt
sudo tree /Applications >> Applications${Current_Time}.txt
sudo tree /etc >> etc${Current_Time}.txt
sudo tree /Library >>Library${Current_Time}.txt
sudo tree /home >> home${Current_Time}.txt
sudo tree /Network >> Network${Current_Time}.txt
sudo tree /System >> System${Current_Time}.txt
sudo tree /net >> net${Current_Time}.txt
sudo tree /private >> private${Current_Time}.txt
sudo tree /sbin >> sbin${Current_Time}.txt
sudo tree /bin >> bin${Current_Time}.txt
sudo tree /tmp >> tmp${Current_Time}.txt
sudo tree /cores >> cores${Current_Time}.txt
sudo tree /usr >> usr${Current_Time}.txt
sudo tree /var >> var${Current_Time}.txt
这样整个Mac OS系统的文件目录就都生成了,有哪些文件或者在哪个文件目录下,查找文件就方便的多了,只需要检查生成的文件结构或者diff的所在结果的位置。
正常生成的文件目录:
/private
├── etc
│ ├── afpovertcp.cfg
│ ├── aliases -> postfix/aliases
│ ├── aliases.db
│ ├── apache2
│ │ ├── extra
│ │ │ ├── httpd-autoindex.conf
│ │ │ ├── httpd-dav.conf
│ │ │ ├── httpd-default.conf
│ │ │ ├── httpd-info.conf
│ │ │ ├── httpd-languages.conf
│ │ │ ├── httpd-manual.conf
│ │ │ ├── httpd-mpm.conf
│ │ │ ├── httpd-multilang-errordoc.conf
│ │ │ ├── httpd-ssl.conf
│ │ │ ├── httpd-userdir.conf
│ │ │ ├── httpd-vhosts.conf
│ │ │ └── proxy-html.conf
│ │ ├── httpd.conf
│ │ ├── httpd.conf.pre-update
│ │ ├── magic
│ │ ├── mime.types
│ │ ├── original
│ │ │ ├── extra
│ │ │ │ ├── httpd-autoindex.conf
│ │ │ │ ├── httpd-dav.conf
│ │ │ │ ├── httpd-default.conf
│ │ │ │ ├── httpd-info.conf
│ │ │ │ ├── httpd-languages.conf
│ │ │ │ ├── httpd-manual.conf
│ │ │ │ ├── httpd-mpm.conf
│ │ │ │ ├── httpd-multilang-errordoc.conf
│ │ │ │ ├── httpd-ssl.conf
│ │ │ │ ├── httpd-userdir.conf
│ │ │ │ ├── httpd-vhosts.conf
│ │ │ │ └── proxy-html.conf
│ │ │ └── httpd.conf
│ │ ├── other
│ │ │ └── php5.conf
│ │ └── users
│ │ ├── Guest.conf
│ │ └── iobit.conf
│ ├── asl
比较结果:
Juliuss-iMac:~ io$ diff /Users/io/Documents/path/private201808231130.txt /Users/io/Documents/path/private201808231321.txt
286a287,290
> │ ├── 95E95251-E2C7-4231-8CD9-1584FFD0BC59
> │ │ └── 9D535B45-5E82-44F0-8142-1CA5A078C5B9
> │ ├── E1E122CD-7EF1-4353-929D-3CA5DBDFAE6B
> │ │ └── C68D6211-E606-41E0-91BE-B65CAC789B7B
289,290c293,295
< │ └── com.apple.launchd.cR6KwCEWNu
< │ └── Listeners
---
> │ ├── com.apple.launchd.cR6KwCEWNu
> │ │ └── Listeners
> │ └── tmp
313a319
> │ │ │ ├── app.com.5Kel44UXJRL_BjOFVKh7UZO8CvVrSQIG.playlist
316a323,325
> │ │ │ ├── app.com.avantis.dlm.playlist
> │ │ │ ├── app.com.booking.booking.playlist
> │ │ │ ├── app.com.install.8a907b7e7aeb.playlist
439a449
> │ │ │ ├── logdata.TTL.20180826_20180823T043108.tracev3
441a452
> │ │ │ ├── logdata.TTL.20180830_20180823T043108.tracev3
443c454,455
< │ │ │ └── logdata.TTL.20180906_20180823T025519.tracev3
---
> │ │ │ ├── logdata.TTL.20180906_20180823T025519.tracev3
> │ │ │ └── logdata.TTL.20180906_20180823T043108.tracev3
861a874
> │ │ ├── 3DCEE79B-BF98-43E9-B5CB-940DC9A71A7E.coalitions.ZCYwFN.stats
864a878
> │ │ ├── 3DCEE79B-BF98-43E9-B5CB-940DC9A71A7E.microstackshots.L3y16Q.gz
899a914
> │ │ │ ├── 8BB5DC92973472AC861B5E47344C7E
。。。。。。。。。。。。。
有哪个目录下的哪个文件发生了改变,是不是很容易就发现了啊!
本文来自博客园,作者:{Julius},转载请注明原文链接:https://www.cnblogs.com/bestechshare/p/16447670.html
可微信加我,了解更多,WeChat:{KingisOK}